[Libva] [Libva-intel-driver][PATCH] Avoid potential NULL pointer access

Xiang, Haihao haihao.xiang at intel.com
Mon May 23 04:20:16 UTC 2016


The issue is reported by Klocwork

Signed-off-by: Xiang, Haihao <haihao.xiang at intel.com>
---
 src/gen9_vdenc.c     | 6 ++++++
 src/i965_drv_video.c | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/gen9_vdenc.c b/src/gen9_vdenc.c
index f239f29..3cc897e 100644
--- a/src/gen9_vdenc.c
+++ b/src/gen9_vdenc.c
@@ -2221,6 +2221,9 @@ gen9_vdenc_init_img_states(VADriverContextP ctx,
 
     pbuffer = i965_map_gpe_resource(&vdenc_context->vdenc_avc_image_state_res);
 
+    if (!pbuffer)
+        return;
+
     mfx_img_cmd = (struct gen9_mfx_avc_img_state *)pbuffer;
     gen9_vdenc_init_mfx_avc_img_state(ctx, encode_state, encoder_context, mfx_img_cmd);
     pbuffer += sizeof(*mfx_img_cmd);
@@ -2245,6 +2248,9 @@ gen9_vdenc_huc_brc_update_constant_data(VADriverContextP ctx,
 
     pbuffer = i965_map_gpe_resource(&vdenc_context->brc_constant_data_res);
 
+    if (!pbuffer)
+        return;
+
     if (vdenc_context->internal_rate_mode == I965_BRC_VBR) {
         memcpy(gen9_brc_update_constant_data.dist_qp_adj_tab_i, dist_qp_adj_tab_i_vbr, sizeof(dist_qp_adj_tab_i_vbr));
         memcpy(gen9_brc_update_constant_data.dist_qp_adj_tab_p, dist_qp_adj_tab_p_vbr, sizeof(dist_qp_adj_tab_p_vbr));
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 2c70a29..259bfc0 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -2543,10 +2543,12 @@ i965_MapBuffer(VADriverContextP ctx,
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct object_buffer *obj_buffer = BUFFER(buf_id);
     VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
-    struct object_context *obj_context = CONTEXT(obj_buffer->context_id);
+    struct object_context *obj_context;
 
     ASSERT_RET(obj_buffer && obj_buffer->buffer_store, VA_STATUS_ERROR_INVALID_BUFFER);
 
+    obj_context = CONTEXT(obj_buffer->context_id);
+
     /* When the wrapper_buffer exists, it will wrapper to the
      * buffer allocated from backend driver.
      */
-- 
1.9.1



More information about the Libva mailing list