i965_drv_video: release mfd context
authorXiang, Haihao <haihao.xiang@intel.com>
Mon, 15 Nov 2010 07:05:29 +0000 (15:05 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Mon, 6 Dec 2010 04:50:05 +0000 (12:50 +0800)
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
i965_drv_video/gen6_mfd.c

index 9da9e6d..c6fab96 100644 (file)
@@ -1425,27 +1425,32 @@ gen6_mfd_terminate(VADriverContextP ctx)
     struct i965_media_state *media_state = &i965->media_state;
     struct gen6_mfd_context *gen6_mfd_context = media_state->private_context;
 
-    dri_bo_unreference(gen6_mfd_context->post_deblocking_output.bo);
-    gen6_mfd_context->post_deblocking_output.bo = NULL;
+    if (gen6_mfd_context) {
+        dri_bo_unreference(gen6_mfd_context->post_deblocking_output.bo);
+        gen6_mfd_context->post_deblocking_output.bo = NULL;
 
-    dri_bo_unreference(gen6_mfd_context->pre_deblocking_output.bo);
-    gen6_mfd_context->pre_deblocking_output.bo = NULL;
+        dri_bo_unreference(gen6_mfd_context->pre_deblocking_output.bo);
+        gen6_mfd_context->pre_deblocking_output.bo = NULL;
 
-    dri_bo_unreference(gen6_mfd_context->intra_row_store_scratch_buffer.bo);
-    gen6_mfd_context->intra_row_store_scratch_buffer.bo = NULL;
+        dri_bo_unreference(gen6_mfd_context->intra_row_store_scratch_buffer.bo);
+        gen6_mfd_context->intra_row_store_scratch_buffer.bo = NULL;
 
-    dri_bo_unreference(gen6_mfd_context->deblocking_filter_row_store_scratch_buffer.bo);
-    gen6_mfd_context->deblocking_filter_row_store_scratch_buffer.bo = NULL;
+        dri_bo_unreference(gen6_mfd_context->deblocking_filter_row_store_scratch_buffer.bo);
+        gen6_mfd_context->deblocking_filter_row_store_scratch_buffer.bo = NULL;
 
-    dri_bo_unreference(gen6_mfd_context->bsd_mpc_row_store_scratch_buffer.bo);
-    gen6_mfd_context->bsd_mpc_row_store_scratch_buffer.bo = NULL;
+        dri_bo_unreference(gen6_mfd_context->bsd_mpc_row_store_scratch_buffer.bo);
+        gen6_mfd_context->bsd_mpc_row_store_scratch_buffer.bo = NULL;
 
-    dri_bo_unreference(gen6_mfd_context->mpr_row_store_scratch_buffer.bo);
-    gen6_mfd_context->mpr_row_store_scratch_buffer.bo = NULL;
+        dri_bo_unreference(gen6_mfd_context->mpr_row_store_scratch_buffer.bo);
+        gen6_mfd_context->mpr_row_store_scratch_buffer.bo = NULL;
 
-    dri_bo_unreference(gen6_mfd_context->bitplane_read_buffer.bo);
-    gen6_mfd_context->bitplane_read_buffer.bo = NULL;
+        dri_bo_unreference(gen6_mfd_context->bitplane_read_buffer.bo);
+        gen6_mfd_context->bitplane_read_buffer.bo = NULL;
+
+        free(gen6_mfd_context);
+    }
 
+    media_state->private_context = NULL;
     return True;
 }