diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2011-08-25 06:21:21 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-09-06 14:03:26 -0400 |
commit | a6bd62be5a3e3a2eee9c0c1d7c04cb52cff3e073 (patch) | |
tree | b0ab018a7b3fce14962ab5bbeda5d84d7307b1fa | |
parent | 1d0c86cad38678fa42f6d048a7b9e4057c8c16fc (diff) |
[media] media: mem2mem: eliminate possible NULL pointer dereference
This patch removes the possible NULL pointer dereference in mem2mem
code.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
CC: Pawel Osciak <pawel@osciak.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/v4l2-mem2mem.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/media/video/v4l2-mem2mem.c b/drivers/media/video/v4l2-mem2mem.c index 3b15bf5892a8..975d0fa938c6 100644 --- a/drivers/media/video/v4l2-mem2mem.c +++ b/drivers/media/video/v4l2-mem2mem.c | |||
@@ -97,11 +97,12 @@ void *v4l2_m2m_next_buf(struct v4l2_m2m_queue_ctx *q_ctx) | |||
97 | 97 | ||
98 | spin_lock_irqsave(&q_ctx->rdy_spinlock, flags); | 98 | spin_lock_irqsave(&q_ctx->rdy_spinlock, flags); |
99 | 99 | ||
100 | if (list_empty(&q_ctx->rdy_queue)) | 100 | if (list_empty(&q_ctx->rdy_queue)) { |
101 | goto end; | 101 | spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags); |
102 | return NULL; | ||
103 | } | ||
102 | 104 | ||
103 | b = list_entry(q_ctx->rdy_queue.next, struct v4l2_m2m_buffer, list); | 105 | b = list_entry(q_ctx->rdy_queue.next, struct v4l2_m2m_buffer, list); |
104 | end: | ||
105 | spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags); | 106 | spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags); |
106 | return &b->vb; | 107 | return &b->vb; |
107 | } | 108 | } |
@@ -117,12 +118,13 @@ void *v4l2_m2m_buf_remove(struct v4l2_m2m_queue_ctx *q_ctx) | |||
117 | unsigned long flags; | 118 | unsigned long flags; |
118 | 119 | ||
119 | spin_lock_irqsave(&q_ctx->rdy_spinlock, flags); | 120 | spin_lock_irqsave(&q_ctx->rdy_spinlock, flags); |
120 | if (!list_empty(&q_ctx->rdy_queue)) { | 121 | if (list_empty(&q_ctx->rdy_queue)) { |
121 | b = list_entry(q_ctx->rdy_queue.next, struct v4l2_m2m_buffer, | 122 | spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags); |
122 | list); | 123 | return NULL; |
123 | list_del(&b->list); | ||
124 | q_ctx->num_rdy--; | ||
125 | } | 124 | } |
125 | b = list_entry(q_ctx->rdy_queue.next, struct v4l2_m2m_buffer, list); | ||
126 | list_del(&b->list); | ||
127 | q_ctx->num_rdy--; | ||
126 | spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags); | 128 | spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags); |
127 | 129 | ||
128 | return &b->vb; | 130 | return &b->vb; |