hardware/intel/intel-driver
リビジョン | d117b9d30a00c811eb7e636c772979de846d30c8 (tree) |
---|---|
日時 | 2015-09-06 13:53:35 |
作者 | Lim Siew Hoon <siew.hoon.lim@inte...> |
コミッター | Xiang, Haihao |
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>
@@ -650,6 +650,7 @@ VAStatus intel_mfc_avc_prepare(VADriverContextP ctx, | ||
650 | 650 | |
651 | 651 | if ( obj_surface->private_data == NULL) { |
652 | 652 | gen6_avc_surface = calloc(sizeof(GenAvcSurface), 1); |
653 | + assert(gen6_avc_surface); | |
653 | 654 | gen6_avc_surface->dmv_top = |
654 | 655 | dri_bo_alloc(i965->intel.bufmgr, |
655 | 656 | "Buffer", |
@@ -696,6 +697,7 @@ VAStatus intel_mfc_avc_prepare(VADriverContextP ctx, | ||
696 | 697 | if ( obj_surface->private_data == NULL) { |
697 | 698 | |
698 | 699 | gen6_avc_surface = calloc(sizeof(GenAvcSurface), 1); |
700 | + assert(gen6_avc_surface); | |
699 | 701 | gen6_avc_surface->dmv_top = |
700 | 702 | dri_bo_alloc(i965->intel.bufmgr, |
701 | 703 | "Buffer", |
@@ -61,6 +61,7 @@ gen6_mfd_init_avc_surface(VADriverContextP ctx, | ||
61 | 61 | |
62 | 62 | if (!gen6_avc_surface) { |
63 | 63 | gen6_avc_surface = calloc(sizeof(GenAvcSurface), 1); |
64 | + assert(gen6_avc_surface); | |
64 | 65 | gen6_avc_surface->base.frame_store_id = -1; |
65 | 66 | assert((obj_surface->size & 0x3f) == 0); |
66 | 67 | obj_surface->private_data = gen6_avc_surface; |
@@ -67,6 +67,7 @@ gen75_mfd_init_avc_surface(VADriverContextP ctx, | ||
67 | 67 | |
68 | 68 | if (!gen7_avc_surface) { |
69 | 69 | gen7_avc_surface = calloc(sizeof(GenAvcSurface), 1); |
70 | + assert(gen7_avc_surface); | |
70 | 71 | gen7_avc_surface->base.frame_store_id = -1; |
71 | 72 | assert((obj_surface->size & 0x3f) == 0); |
72 | 73 | obj_surface->private_data = gen7_avc_surface; |
@@ -1511,6 +1512,7 @@ gen75_mfd_init_vc1_surface(VADriverContextP ctx, | ||
1511 | 1512 | |
1512 | 1513 | if (!gen7_vc1_surface) { |
1513 | 1514 | gen7_vc1_surface = calloc(sizeof(struct gen7_vc1_surface), 1); |
1515 | + assert(gen7_vc1_surface); | |
1514 | 1516 | assert((obj_surface->size & 0x3f) == 0); |
1515 | 1517 | obj_surface->private_data = gen7_vc1_surface; |
1516 | 1518 | } |
@@ -3250,6 +3252,7 @@ gen75_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config | ||
3250 | 3252 | struct gen7_mfd_context *gen7_mfd_context = calloc(1, sizeof(struct gen7_mfd_context)); |
3251 | 3253 | int i; |
3252 | 3254 | |
3255 | + assert(gen7_mfd_context); | |
3253 | 3256 | gen7_mfd_context->base.destroy = gen75_mfd_context_destroy; |
3254 | 3257 | gen7_mfd_context->base.run = gen75_mfd_decode_picture; |
3255 | 3258 | gen7_mfd_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0); |
@@ -266,6 +266,7 @@ gen75_proc_context_init(VADriverContextP ctx, | ||
266 | 266 | struct intel_video_process_context *proc_context |
267 | 267 | = calloc(1, sizeof(struct intel_video_process_context)); |
268 | 268 | |
269 | + assert(proc_context); | |
269 | 270 | proc_context->base.destroy = gen75_proc_context_destroy; |
270 | 271 | proc_context->base.run = gen75_proc_picture; |
271 | 272 |
@@ -1037,6 +1037,8 @@ Bool gen75_vme_context_init(VADriverContextP ctx, struct intel_encoder_context * | ||
1037 | 1037 | |
1038 | 1038 | break; |
1039 | 1039 | } |
1040 | + | |
1041 | + assert(vme_context); | |
1040 | 1042 | vme_context->vme_kernel_sum = i965_kernel_num; |
1041 | 1043 | vme_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6; |
1042 | 1044 |
@@ -871,6 +871,7 @@ vpp_gpe_context_init(VADriverContextP ctx) | ||
871 | 871 | { |
872 | 872 | struct i965_driver_data *i965 = i965_driver_data(ctx); |
873 | 873 | struct vpp_gpe_context *vpp_gpe_ctx = calloc(1, sizeof(struct vpp_gpe_context)); |
874 | + assert(vpp_gpe_ctx); | |
874 | 875 | struct i965_gpe_context *gpe_ctx = &(vpp_gpe_ctx->gpe_ctx); |
875 | 876 | |
876 | 877 | assert(IS_HASWELL(i965->intel.device_info) || |
@@ -1763,6 +1763,7 @@ struct intel_vebox_context * gen75_vebox_context_init(VADriverContextP ctx) | ||
1763 | 1763 | struct intel_vebox_context *proc_context = calloc(1, sizeof(struct intel_vebox_context)); |
1764 | 1764 | int i; |
1765 | 1765 | |
1766 | + assert(proc_context); | |
1766 | 1767 | proc_context->batch = intel_batchbuffer_new(intel, I915_EXEC_VEBOX, 0); |
1767 | 1768 | |
1768 | 1769 | for (i = 0; i < ARRAY_ELEMS(proc_context->frame_store); i++) |
@@ -65,6 +65,7 @@ gen7_mfd_init_avc_surface(VADriverContextP ctx, | ||
65 | 65 | |
66 | 66 | if (!gen7_avc_surface) { |
67 | 67 | gen7_avc_surface = calloc(sizeof(GenAvcSurface), 1); |
68 | + assert(gen7_avc_surface); | |
68 | 69 | gen7_avc_surface->base.frame_store_id = -1; |
69 | 70 | assert((obj_surface->size & 0x3f) == 0); |
70 | 71 | obj_surface->private_data = gen7_avc_surface; |
@@ -1246,6 +1247,7 @@ gen7_mfd_init_vc1_surface(VADriverContextP ctx, | ||
1246 | 1247 | |
1247 | 1248 | if (!gen7_vc1_surface) { |
1248 | 1249 | gen7_vc1_surface = calloc(sizeof(struct gen7_vc1_surface), 1); |
1250 | + assert(gen7_vc1_surface); | |
1249 | 1251 | assert((obj_surface->size & 0x3f) == 0); |
1250 | 1252 | obj_surface->private_data = gen7_vc1_surface; |
1251 | 1253 | } |
@@ -2729,6 +2731,7 @@ gen7_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) | ||
2729 | 2731 | struct gen7_mfd_context *gen7_mfd_context = calloc(1, sizeof(struct gen7_mfd_context)); |
2730 | 2732 | int i; |
2731 | 2733 | |
2734 | + assert(gen7_mfd_context); | |
2732 | 2735 | gen7_mfd_context->base.destroy = gen7_mfd_context_destroy; |
2733 | 2736 | gen7_mfd_context->base.run = gen7_mfd_decode_picture; |
2734 | 2737 | gen7_mfd_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0); |
@@ -1031,6 +1031,7 @@ Bool gen7_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e | ||
1031 | 1031 | struct gen6_vme_context *vme_context = calloc(1, sizeof(struct gen6_vme_context)); |
1032 | 1032 | struct i965_kernel *vme_kernel_list = NULL; |
1033 | 1033 | |
1034 | + assert(vme_context); | |
1034 | 1035 | vme_context->gpe_context.surface_state_binding_table.length = |
1035 | 1036 | (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6; |
1036 | 1037 |
@@ -4571,7 +4571,7 @@ static VAStatus gen8_mfc_pipeline(VADriverContextP ctx, | ||
4571 | 4571 | Bool gen8_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context) |
4572 | 4572 | { |
4573 | 4573 | struct gen6_mfc_context *mfc_context = calloc(1, sizeof(struct gen6_mfc_context)); |
4574 | - | |
4574 | + assert(mfc_context); | |
4575 | 4575 | mfc_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6; |
4576 | 4576 | |
4577 | 4577 | mfc_context->gpe_context.idrt.max_entries = MAX_GPE_KERNELS; |
@@ -1338,6 +1338,7 @@ Bool gen8_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e | ||
1338 | 1338 | //If the codec is JPEG, bypass VME |
1339 | 1339 | if(encoder_context->codec != CODEC_JPEG) { |
1340 | 1340 | vme_context = calloc(1, sizeof(struct gen6_vme_context)); |
1341 | + assert(vme_context); | |
1341 | 1342 | vme_context->vme_kernel_sum = i965_kernel_num; |
1342 | 1343 | vme_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6; |
1343 | 1344 |
@@ -1717,6 +1717,7 @@ Bool gen9_mfc_context_init(VADriverContextP ctx, struct intel_encoder_context *e | ||
1717 | 1717 | return gen8_mfc_context_init(ctx, encoder_context); |
1718 | 1718 | |
1719 | 1719 | mfc_context = calloc(1, sizeof(struct gen6_mfc_context)); |
1720 | + assert(mfc_context); | |
1720 | 1721 | mfc_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6; |
1721 | 1722 | |
1722 | 1723 | mfc_context->gpe_context.idrt.max_entries = MAX_GPE_KERNELS; |
@@ -1984,6 +1984,7 @@ VAStatus intel_hcpe_hevc_prepare(VADriverContextP ctx, | ||
1984 | 1984 | |
1985 | 1985 | hevc_encoder_surface = calloc(sizeof(GenHevcSurface), 1); |
1986 | 1986 | |
1987 | + assert(hevc_encoder_surface); | |
1987 | 1988 | hevc_encoder_surface->motion_vector_temporal_bo = |
1988 | 1989 | dri_bo_alloc(i965->intel.bufmgr, |
1989 | 1990 | "motion vector temporal buffer", |
@@ -2583,6 +2584,7 @@ Bool gen9_hcpe_context_init(VADriverContextP ctx, struct intel_encoder_context * | ||
2583 | 2584 | { |
2584 | 2585 | struct gen9_hcpe_context *hcpe_context = calloc(1, sizeof(struct gen9_hcpe_context)); |
2585 | 2586 | |
2587 | + assert(hcpe_context); | |
2586 | 2588 | hcpe_context->pipe_mode_select = gen9_hcpe_pipe_mode_select; |
2587 | 2589 | hcpe_context->set_surface_state = gen9_hcpe_surface_state; |
2588 | 2590 | hcpe_context->ind_obj_base_addr_state = gen9_hcpe_ind_obj_base_addr_state; |
@@ -77,6 +77,7 @@ gen9_hcpd_init_hevc_surface(VADriverContextP ctx, | ||
77 | 77 | |
78 | 78 | if (!gen9_hevc_surface) { |
79 | 79 | gen9_hevc_surface = calloc(sizeof(GenHevcSurface), 1); |
80 | + assert(gen9_hevc_surface); | |
80 | 81 | gen9_hevc_surface->base.frame_store_id = -1; |
81 | 82 | obj_surface->private_data = gen9_hevc_surface; |
82 | 83 | } |
@@ -1817,6 +1817,8 @@ Bool gen9_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *e | ||
1817 | 1817 | |
1818 | 1818 | break; |
1819 | 1819 | } |
1820 | + | |
1821 | + assert(vme_context); | |
1820 | 1822 | vme_context->vme_kernel_sum = i965_kernel_num; |
1821 | 1823 | vme_context->gpe_context.surface_state_binding_table.length = (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_MEDIA_SURFACES_GEN6; |
1822 | 1824 |
@@ -51,6 +51,7 @@ i965_avc_bsd_init_avc_bsd_surface(VADriverContextP ctx, | ||
51 | 51 | |
52 | 52 | if (!avc_bsd_surface) { |
53 | 53 | avc_bsd_surface = calloc(sizeof(GenAvcSurface), 1); |
54 | + assert(avc_bsd_surface); | |
54 | 55 | avc_bsd_surface->base.frame_store_id = -1; |
55 | 56 | assert((obj_surface->size & 0x3f) == 0); |
56 | 57 | obj_surface->private_data = avc_bsd_surface; |
@@ -674,6 +674,7 @@ intel_enc_hw_context_init(VADriverContextP ctx, | ||
674 | 674 | struct intel_encoder_context *encoder_context = calloc(1, sizeof(struct intel_encoder_context)); |
675 | 675 | int i; |
676 | 676 | |
677 | + assert(encoder_context); | |
677 | 678 | encoder_context->base.destroy = intel_encoder_context_destroy; |
678 | 679 | encoder_context->base.run = intel_encoder_end_picture; |
679 | 680 | encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0); |
@@ -338,6 +338,7 @@ g4x_dec_hw_context_init(VADriverContextP ctx, struct object_config *obj_config) | ||
338 | 338 | struct intel_driver_data *intel = intel_driver_data(ctx); |
339 | 339 | struct i965_media_context *media_context = calloc(1, sizeof(struct i965_media_context)); |
340 | 340 | |
341 | + assert(media_context); | |
341 | 342 | media_context->base.destroy = i965_media_context_destroy; |
342 | 343 | media_context->base.run = i965_media_decode_picture; |
343 | 344 | 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 | ||
368 | 369 | struct intel_driver_data *intel = intel_driver_data(ctx); |
369 | 370 | struct i965_media_context *media_context = calloc(1, sizeof(struct i965_media_context)); |
370 | 371 | |
372 | + assert(media_context); | |
371 | 373 | media_context->base.destroy = i965_media_context_destroy; |
372 | 374 | media_context->base.run = i965_media_decode_picture; |
373 | 375 | media_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER, 0); |
@@ -844,6 +844,7 @@ i965_media_h264_dec_context_init(VADriverContextP ctx, struct i965_media_context | ||
844 | 844 | sizeof(h264_avc_kernels_gen5[0]))); |
845 | 845 | assert(NUM_AVC_MC_INTERFACES == (sizeof(avc_mc_kernel_offset_gen5) / |
846 | 846 | sizeof(avc_mc_kernel_offset_gen5[0]))); |
847 | + assert(i965_h264_context); | |
847 | 848 | if (IS_IRONLAKE(i965->intel.device_info)) { |
848 | 849 | memcpy(i965_h264_context->avc_kernels, h264_avc_kernels_gen5, sizeof(i965_h264_context->avc_kernels)); |
849 | 850 | avc_mc_kernel_offset = avc_mc_kernel_offset_gen5; |
@@ -979,6 +979,7 @@ i965_media_mpeg2_dec_context_init(VADriverContextP ctx, struct i965_media_contex | ||
979 | 979 | int i; |
980 | 980 | |
981 | 981 | i965_mpeg2_context = calloc(1, sizeof(struct i965_mpeg2_context)); |
982 | + assert(i965_mpeg2_context); | |
982 | 983 | i965_mpeg2_context->wa_slice_vertical_position = -1; |
983 | 984 | |
984 | 985 | /* kernel */ |
@@ -5510,6 +5510,7 @@ i965_post_processing_init(VADriverContextP ctx) | ||
5510 | 5510 | if (HAS_VPP(i965)) { |
5511 | 5511 | if (pp_context == NULL) { |
5512 | 5512 | pp_context = calloc(1, sizeof(*pp_context)); |
5513 | + assert(pp_context); | |
5513 | 5514 | i965->codec_info->post_processing_context_init(ctx, pp_context, i965->pp_batch); |
5514 | 5515 | i965->pp_context = pp_context; |
5515 | 5516 | } |
@@ -95,6 +95,7 @@ intel_batchbuffer_new(struct intel_driver_data *intel, int flag, int buffer_size | ||
95 | 95 | buffer_size = MAX_BATCH_SIZE; |
96 | 96 | } |
97 | 97 | |
98 | + assert(batch); | |
98 | 99 | batch->intel = intel; |
99 | 100 | batch->flag = flag; |
100 | 101 | batch->run = drm_intel_bo_mrb_exec; |