media: s5p_mfc: Check the return value of allocation routine
authorZhaowei Yuan <zhaowei.yuan@samsung.com>
Fri, 1 Aug 2014 05:51:12 +0000 (13:51 +0800)
committerChanho Park <chanho61.park@samsung.com>
Tue, 18 Nov 2014 03:00:23 +0000 (12:00 +0900)
Check the return value of allocation routine and deal with failure.

Change-Id: Ie7df5962de5928812d1a81bb648258314c0699d1
Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com>
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 414e450..ff98410
@@ -687,10 +687,18 @@ static int vidioc_streamon(struct file *file, void *priv,
                        ctx->src_bufs_cnt = 0;
                        ctx->capture_state = QUEUE_FREE;
                        ctx->output_state = QUEUE_FREE;
-                       s5p_mfc_hw_call(dev->mfc_ops, alloc_instance_buffer,
+                       ret = s5p_mfc_hw_call(dev->mfc_ops, alloc_instance_buffer,
                                        ctx);
-                       s5p_mfc_hw_call(dev->mfc_ops, alloc_dec_temp_buffers,
+                       if(ret)
+                               return ret;
+
+                       ret = s5p_mfc_hw_call(dev->mfc_ops, alloc_dec_temp_buffers,
                                        ctx);
+                       if(ret) {
+                               s5p_mfc_hw_call(dev->mfc_ops, release_instance_buffer, ctx);
+                               return ret;
+                       }
+
                        set_work_bit_irqsave(ctx);
                        s5p_mfc_clean_ctx_int_flags(ctx);
                        s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);