• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/intel/intel-driver


Commit MetaInfo

修订版d117b9d30a00c811eb7e636c772979de846d30c8 (tree)
时间2015-09-06 13:53:35
作者Lim Siew Hoon <siew.hoon.lim@inte...>
CommiterXiang, Haihao

Log Message

Fix klockwork critical message hit on calloc function usage

The calloc function maybe return NULL, it will causing
memory access violation if continue using NULL C structure.
Add assert function to do checking on its.

bugzilla:
https://bugs.freedesktop.org/show_bug.cgi?id=91699

Signed-off-by: Lim Siew Hoon <siew.hoon.lim@intel.com>

更改概述

差异

--- a/src/gen6_mfc_common.c
+++ b/src/gen6_mfc_common.c
@@ -650,6 +650,7 @@ VAStatus intel_mfc_avc_prepare(VADriverContextP ctx,
650650
651651 if ( obj_surface->private_data == NULL) {
652652 gen6_avc_surface = calloc(sizeof(GenAvcSurface), 1);
653+ assert(gen6_avc_surface);
653654 gen6_avc_surface->dmv_top =
654655 dri_bo_alloc(i965->intel.bufmgr,
655656 "Buffer",
@@ -696,6 +697,7 @@ VAStatus intel_mfc_avc_prepare(VADriverContextP ctx,
696697 if ( obj_surface->private_data == NULL) {
697698
698699 gen6_avc_surface = calloc(sizeof(GenAvcSurface), 1);
700+ assert(gen6_avc_surface);
699701 gen6_avc_surface->dmv_top =
700702 dri_bo_alloc(i965->intel.bufmgr,
701703 "Buffer",
--- a/src/gen6_mfd.c
+++ b/src/gen6_mfd.c
@@ -61,6 +61,7 @@ gen6_mfd_init_avc_surface(VADriverContextP ctx,
6161
6262 if (!gen6_avc_surface) {
6363 gen6_avc_surface = calloc(sizeof(GenAvcSurface), 1);
64+ assert(gen6_avc_surface);
6465 gen6_avc_surface->base.frame_store_id = -1;
6566 assert((obj_surface->size & 0x3f) == 0);
6667 obj_surface->private_data = gen6_avc_surface;
--- a/src/gen75_mfd.c
+++ b/src/gen75_mfd.c
@@ -67,6 +67,7 @@ gen75_mfd_init_avc_surface(VADriverContextP ctx,
6767
6868 if (!gen7_avc_surface) {
6969 gen7_avc_surface = calloc(sizeof(GenAvcSurface), 1);
70+ assert(gen7_avc_surface);
7071 gen7_avc_surface->base.frame_store_id = -1;
7172 assert((obj_surface->size & 0x3f) == 0);
7273 obj_surface->private_data = gen7_avc_surface;
@@ -1511,6 +1512,7 @@ gen75_mfd_init_vc1_surface(VADriverContextP ctx,
15111512
15121513 if (!gen7_vc1_surface) {
15131514 gen7_vc1_surface = calloc(sizeof(struct gen7_vc1_surface), 1);
1515+ assert(gen7_vc1_surface);
15141516 assert((obj_surface->size & 0x3f) == 0);
15151517 obj_surface->private_data = gen7_vc1_surface;
15161518 }
@@ -3250,6 +3252,7 @@ gen75_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config
32503252 struct gen7_mfd_context *gen7_mfd_context = calloc(1, sizeof(struct gen7_mfd_context));
32513253 int i;
32523254
3255+ assert(gen7_mfd_context);
32533256 gen7_mfd_context->base.destroy = gen75_mfd_context_destroy;
32543257 gen7_mfd_context->base.run = gen75_mfd_decode_picture;
32553258 gen7_mfd_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
--- a/src/gen75_picture_process.c
+++ b/src/gen75_picture_process.c
@@ -266,6 +266,7 @@ gen75_proc_context_init(VADriverContextP ctx,
266266 struct intel_video_process_context *proc_context
267267 = calloc(1, sizeof(struct intel_video_process_context));
268268
269+ assert(proc_context);
269270 proc_context->base.destroy = gen75_proc_context_destroy;
270271 proc_context->base.run = gen75_proc_picture;
271272
--- a/src/gen75_vme.c
+++ b/src/gen75_vme.c
@@ -1037,6 +1037,8 @@ Bool gen75_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *
10371037
10381038 break;
10391039 }
1040+
1041+ assert(vme_context);
10401042 vme_context->vme_kernel_sum = i965_kernel_num;
10411043 vme_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6;
10421044
--- a/src/gen75_vpp_gpe.c
+++ b/src/gen75_vpp_gpe.c
@@ -871,6 +871,7 @@ vpp_gpe_context_init(VADriverContextP ctx)
871871 {
872872 struct i965_driver_data *i965 = i965_driver_data(ctx);
873873 struct vpp_gpe_context *vpp_gpe_ctx = calloc(1, sizeof(struct vpp_gpe_context));
874+ assert(vpp_gpe_ctx);
874875 struct i965_gpe_context *gpe_ctx = &(vpp_gpe_ctx->gpe_ctx);
875876
876877 assert(IS_HASWELL(i965->intel.device_info) ||
--- a/src/gen75_vpp_vebox.c
+++ b/src/gen75_vpp_vebox.c
@@ -1763,6 +1763,7 @@ struct intel_vebox_context * gen75_vebox_context_init(VADriverContextP ctx)
17631763 struct intel_vebox_context *proc_context = calloc(1, sizeof(struct intel_vebox_context));
17641764 int i;
17651765
1766+ assert(proc_context);
17661767 proc_context->batch = intel_batchbuffer_new(intel, I915_EXEC_VEBOX, 0);
17671768
17681769 for (i = 0; i < ARRAY_ELEMS(proc_context->frame_store); i++)
--- a/src/gen7_mfd.c
+++ b/src/gen7_mfd.c
@@ -65,6 +65,7 @@ gen7_mfd_init_avc_surface(VADriverContextP ctx,
6565
6666 if (!gen7_avc_surface) {
6767 gen7_avc_surface = calloc(sizeof(GenAvcSurface), 1);
68+ assert(gen7_avc_surface);
6869 gen7_avc_surface->base.frame_store_id = -1;
6970 assert((obj_surface->size & 0x3f) == 0);
7071 obj_surface->private_data = gen7_avc_surface;
@@ -1246,6 +1247,7 @@ gen7_mfd_init_vc1_surface(VADriverContextP ctx,
12461247
12471248 if (!gen7_vc1_surface) {
12481249 gen7_vc1_surface = calloc(sizeof(struct gen7_vc1_surface), 1);
1250+ assert(gen7_vc1_surface);
12491251 assert((obj_surface->size & 0x3f) == 0);
12501252 obj_surface->private_data = gen7_vc1_surface;
12511253 }
@@ -2729,6 +2731,7 @@ gen7_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
27292731 struct gen7_mfd_context *gen7_mfd_context = calloc(1, sizeof(struct gen7_mfd_context));
27302732 int i;
27312733
2734+ assert(gen7_mfd_context);
27322735 gen7_mfd_context->base.destroy = gen7_mfd_context_destroy;
27332736 gen7_mfd_context->base.run = gen7_mfd_decode_picture;
27342737 gen7_mfd_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
--- a/src/gen7_vme.c
+++ b/src/gen7_vme.c
@@ -1031,6 +1031,7 @@ Bool gen7_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e
10311031 struct gen6_vme_context *vme_context = calloc(1, sizeof(struct gen6_vme_context));
10321032 struct i965_kernel *vme_kernel_list = NULL;
10331033
1034+ assert(vme_context);
10341035 vme_context->gpe_context.surface_state_binding_table.length =
10351036 (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6;
10361037
--- a/src/gen8_mfc.c
+++ b/src/gen8_mfc.c
@@ -4571,7 +4571,7 @@ static VAStatus gen8_mfc_pipeline(VADriverContextP ctx,
45714571 Bool gen8_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context)
45724572 {
45734573 struct gen6_mfc_context *mfc_context = calloc(1, sizeof(struct gen6_mfc_context));
4574-
4574+ assert(mfc_context);
45754575 mfc_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6;
45764576
45774577 mfc_context->gpe_context.idrt.max_entries = MAX_GPE_KERNELS;
--- a/src/gen8_vme.c
+++ b/src/gen8_vme.c
@@ -1338,6 +1338,7 @@ Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e
13381338 //If the codec is JPEG, bypass VME
13391339 if(encoder_context->codec != CODEC_JPEG) {
13401340 vme_context = calloc(1, sizeof(struct gen6_vme_context));
1341+ assert(vme_context);
13411342 vme_context->vme_kernel_sum = i965_kernel_num;
13421343 vme_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6;
13431344
--- a/src/gen9_mfc.c
+++ b/src/gen9_mfc.c
@@ -1717,6 +1717,7 @@ Bool gen9_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *e
17171717 return gen8_mfc_context_init(ctx, encoder_context);
17181718
17191719 mfc_context = calloc(1, sizeof(struct gen6_mfc_context));
1720+ assert(mfc_context);
17201721 mfc_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6;
17211722
17221723 mfc_context->gpe_context.idrt.max_entries = MAX_GPE_KERNELS;
--- a/src/gen9_mfc_hevc.c
+++ b/src/gen9_mfc_hevc.c
@@ -1984,6 +1984,7 @@ VAStatus intel_hcpe_hevc_prepare(VADriverContextP ctx,
19841984
19851985 hevc_encoder_surface = calloc(sizeof(GenHevcSurface), 1);
19861986
1987+ assert(hevc_encoder_surface);
19871988 hevc_encoder_surface->motion_vector_temporal_bo =
19881989 dri_bo_alloc(i965->intel.bufmgr,
19891990 "motion vector temporal buffer",
@@ -2583,6 +2584,7 @@ Bool gen9_hcpe_context_init(VADriverContextP ctx, struct intel_encoder_context *
25832584 {
25842585 struct gen9_hcpe_context *hcpe_context = calloc(1, sizeof(struct gen9_hcpe_context));
25852586
2587+ assert(hcpe_context);
25862588 hcpe_context->pipe_mode_select = gen9_hcpe_pipe_mode_select;
25872589 hcpe_context->set_surface_state = gen9_hcpe_surface_state;
25882590 hcpe_context->ind_obj_base_addr_state = gen9_hcpe_ind_obj_base_addr_state;
--- a/src/gen9_mfd.c
+++ b/src/gen9_mfd.c
@@ -77,6 +77,7 @@ gen9_hcpd_init_hevc_surface(VADriverContextP ctx,
7777
7878 if (!gen9_hevc_surface) {
7979 gen9_hevc_surface = calloc(sizeof(GenHevcSurface), 1);
80+ assert(gen9_hevc_surface);
8081 gen9_hevc_surface->base.frame_store_id = -1;
8182 obj_surface->private_data = gen9_hevc_surface;
8283 }
--- a/src/gen9_vme.c
+++ b/src/gen9_vme.c
@@ -1817,6 +1817,8 @@ Bool gen9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e
18171817
18181818 break;
18191819 }
1820+
1821+ assert(vme_context);
18201822 vme_context->vme_kernel_sum = i965_kernel_num;
18211823 vme_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6;
18221824
--- a/src/i965_avc_bsd.c
+++ b/src/i965_avc_bsd.c
@@ -51,6 +51,7 @@ i965_avc_bsd_init_avc_bsd_surface(VADriverContextP ctx,
5151
5252 if (!avc_bsd_surface) {
5353 avc_bsd_surface = calloc(sizeof(GenAvcSurface), 1);
54+ assert(avc_bsd_surface);
5455 avc_bsd_surface->base.frame_store_id = -1;
5556 assert((obj_surface->size & 0x3f) == 0);
5657 obj_surface->private_data = avc_bsd_surface;
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -674,6 +674,7 @@ intel_enc_hw_context_init(VADriverContextP ctx,
674674 struct intel_encoder_context *encoder_context = calloc(1, sizeof(struct intel_encoder_context));
675675 int i;
676676
677+ assert(encoder_context);
677678 encoder_context->base.destroy = intel_encoder_context_destroy;
678679 encoder_context->base.run = intel_encoder_end_picture;
679680 encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
--- a/src/i965_media.c
+++ b/src/i965_media.c
@@ -338,6 +338,7 @@ g4x_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config)
338338 struct intel_driver_data *intel = intel_driver_data(ctx);
339339 struct i965_media_context *media_context = calloc(1, sizeof(struct i965_media_context));
340340
341+ assert(media_context);
341342 media_context->base.destroy = i965_media_context_destroy;
342343 media_context->base.run = i965_media_decode_picture;
343344 media_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
@@ -368,6 +369,7 @@ ironlake_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_con
368369 struct intel_driver_data *intel = intel_driver_data(ctx);
369370 struct i965_media_context *media_context = calloc(1, sizeof(struct i965_media_context));
370371
372+ assert(media_context);
371373 media_context->base.destroy = i965_media_context_destroy;
372374 media_context->base.run = i965_media_decode_picture;
373375 media_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0);
--- a/src/i965_media_h264.c
+++ b/src/i965_media_h264.c
@@ -844,6 +844,7 @@ i965_media_h264_dec_context_init(VADriverContextP ctx, struct i965_media_context
844844 sizeof(h264_avc_kernels_gen5[0])));
845845 assert(NUM_AVC_MC_INTERFACES == (sizeof(avc_mc_kernel_offset_gen5) /
846846 sizeof(avc_mc_kernel_offset_gen5[0])));
847+ assert(i965_h264_context);
847848 if (IS_IRONLAKE(i965->intel.device_info)) {
848849 memcpy(i965_h264_context->avc_kernels, h264_avc_kernels_gen5, sizeof(i965_h264_context->avc_kernels));
849850 avc_mc_kernel_offset = avc_mc_kernel_offset_gen5;
--- a/src/i965_media_mpeg2.c
+++ b/src/i965_media_mpeg2.c
@@ -979,6 +979,7 @@ i965_media_mpeg2_dec_context_init(VADriverContextP ctx, struct i965_media_contex
979979 int i;
980980
981981 i965_mpeg2_context = calloc(1, sizeof(struct i965_mpeg2_context));
982+ assert(i965_mpeg2_context);
982983 i965_mpeg2_context->wa_slice_vertical_position = -1;
983984
984985 /* kernel */
--- a/src/i965_post_processing.c
+++ b/src/i965_post_processing.c
@@ -5510,6 +5510,7 @@ i965_post_processing_init(VADriverContextP ctx)
55105510 if (HAS_VPP(i965)) {
55115511 if (pp_context == NULL) {
55125512 pp_context = calloc(1, sizeof(*pp_context));
5513+ assert(pp_context);
55135514 i965->codec_info->post_processing_context_init(ctx, pp_context, i965->pp_batch);
55145515 i965->pp_context = pp_context;
55155516 }
--- a/src/intel_batchbuffer.c
+++ b/src/intel_batchbuffer.c
@@ -95,6 +95,7 @@ intel_batchbuffer_new(struct intel_driver_data *intel, int flag, int buffer_size
9595 buffer_size = MAX_BATCH_SIZE;
9696 }
9797
98+ assert(batch);
9899 batch->intel = intel;
99100 batch->flag = flag;
100101 batch->run = drm_intel_bo_mrb_exec;