hardware/intel/intel-driver
Revision | 32def604997b4e9f8046b2d4d728de14ceb16c28 (tree) |
---|---|
Time | 2016-05-24 14:11:15 |
Author | Xiang, Haihao <haihao.xiang@inte...> |
Commiter | Xiang, Haihao |
Avoid potential NULL pointer access
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
@@ -2221,6 +2221,9 @@ gen9_vdenc_init_img_states(VADriverContextP ctx, | ||
2221 | 2221 | |
2222 | 2222 | pbuffer = i965_map_gpe_resource(&vdenc_context->vdenc_avc_image_state_res); |
2223 | 2223 | |
2224 | + if (!pbuffer) | |
2225 | + return; | |
2226 | + | |
2224 | 2227 | mfx_img_cmd = (struct gen9_mfx_avc_img_state *)pbuffer; |
2225 | 2228 | gen9_vdenc_init_mfx_avc_img_state(ctx, encode_state, encoder_context, mfx_img_cmd); |
2226 | 2229 | pbuffer += sizeof(*mfx_img_cmd); |
@@ -2245,6 +2248,9 @@ gen9_vdenc_huc_brc_update_constant_data(VADriverContextP ctx, | ||
2245 | 2248 | |
2246 | 2249 | pbuffer = i965_map_gpe_resource(&vdenc_context->brc_constant_data_res); |
2247 | 2250 | |
2251 | + if (!pbuffer) | |
2252 | + return; | |
2253 | + | |
2248 | 2254 | if (vdenc_context->internal_rate_mode == I965_BRC_VBR) { |
2249 | 2255 | memcpy(gen9_brc_update_constant_data.dist_qp_adj_tab_i, dist_qp_adj_tab_i_vbr, sizeof(dist_qp_adj_tab_i_vbr)); |
2250 | 2256 | memcpy(gen9_brc_update_constant_data.dist_qp_adj_tab_p, dist_qp_adj_tab_p_vbr, sizeof(dist_qp_adj_tab_p_vbr)); |
@@ -2543,10 +2543,12 @@ i965_MapBuffer(VADriverContextP ctx, | ||
2543 | 2543 | struct i965_driver_data *i965 = i965_driver_data(ctx); |
2544 | 2544 | struct object_buffer *obj_buffer = BUFFER(buf_id); |
2545 | 2545 | VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; |
2546 | - struct object_context *obj_context = CONTEXT(obj_buffer->context_id); | |
2546 | + struct object_context *obj_context; | |
2547 | 2547 | |
2548 | 2548 | ASSERT_RET(obj_buffer && obj_buffer->buffer_store, VA_STATUS_ERROR_INVALID_BUFFER); |
2549 | 2549 | |
2550 | + obj_context = CONTEXT(obj_buffer->context_id); | |
2551 | + | |
2550 | 2552 | /* When the wrapper_buffer exists, it will wrapper to the |
2551 | 2553 | * buffer allocated from backend driver. |
2552 | 2554 | */ |