[Libva] [libva-intel-driver PATCH] Make sure the pointer is valid before dereferencing it

Xiang, Haihao haihao.xiang at intel.com
Tue Sep 22 22:52:09 PDT 2015


Signed-off-by: Xiang, Haihao <haihao.xiang at intel.com>
---
 src/gen9_mfc_hevc.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/gen9_mfc_hevc.c b/src/gen9_mfc_hevc.c
index 46f8c59..2752bb8 100644
--- a/src/gen9_mfc_hevc.c
+++ b/src/gen9_mfc_hevc.c
@@ -1992,10 +1992,13 @@ VAStatus intel_hcpe_hevc_prepare(VADriverContextP ctx,
         obj_surface->free_private_data = (void *)gen_free_hevc_surface;
     }
     hevc_encoder_surface = (GenHevcSurface *) obj_surface->private_data;
-    hevc_encoder_surface->base.frame_store_id = -1;
-    mfc_context->current_collocated_mv_temporal_buffer[NUM_HCP_CURRENT_COLLOCATED_MV_TEMPORAL_BUFFERS - 1].bo = hevc_encoder_surface->motion_vector_temporal_bo;
 
-    dri_bo_reference(hevc_encoder_surface->motion_vector_temporal_bo);
+    if (hevc_encoder_surface) {
+        hevc_encoder_surface->base.frame_store_id = -1;
+        mfc_context->current_collocated_mv_temporal_buffer[NUM_HCP_CURRENT_COLLOCATED_MV_TEMPORAL_BUFFERS - 1].bo = hevc_encoder_surface->motion_vector_temporal_bo;
+
+        dri_bo_reference(hevc_encoder_surface->motion_vector_temporal_bo);
+    }
 
     mfc_context->surface_state.width = obj_surface->orig_width;
     mfc_context->surface_state.height = obj_surface->orig_height;
@@ -2038,10 +2041,13 @@ VAStatus intel_hcpe_hevc_prepare(VADriverContextP ctx,
             }
 
             hevc_encoder_surface = (GenHevcSurface *) obj_surface->private_data;
-            hevc_encoder_surface->base.frame_store_id = -1;
-            /* Setup MV temporal buffer */
-            mfc_context->current_collocated_mv_temporal_buffer[i].bo = hevc_encoder_surface->motion_vector_temporal_bo;
-            dri_bo_reference(hevc_encoder_surface->motion_vector_temporal_bo);
+
+            if (hevc_encoder_surface) {
+                hevc_encoder_surface->base.frame_store_id = -1;
+                /* Setup MV temporal buffer */
+                mfc_context->current_collocated_mv_temporal_buffer[i].bo = hevc_encoder_surface->motion_vector_temporal_bo;
+                dri_bo_reference(hevc_encoder_surface->motion_vector_temporal_bo);
+            }
         } else {
             break;
         }
-- 
1.9.1



More information about the Libva mailing list