mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-30 08:02:30 +00:00
[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>
This commit is contained in:
parent
1d0c86cad3
commit
a6bd62be5a
1 changed files with 10 additions and 8 deletions
|
@ -97,11 +97,12 @@ void *v4l2_m2m_next_buf(struct v4l2_m2m_queue_ctx *q_ctx)
|
||||||
|
|
||||||
spin_lock_irqsave(&q_ctx->rdy_spinlock, flags);
|
spin_lock_irqsave(&q_ctx->rdy_spinlock, flags);
|
||||||
|
|
||||||
if (list_empty(&q_ctx->rdy_queue))
|
if (list_empty(&q_ctx->rdy_queue)) {
|
||||||
goto end;
|
spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
b = list_entry(q_ctx->rdy_queue.next, struct v4l2_m2m_buffer, list);
|
b = list_entry(q_ctx->rdy_queue.next, struct v4l2_m2m_buffer, list);
|
||||||
end:
|
|
||||||
spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags);
|
spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags);
|
||||||
return &b->vb;
|
return &b->vb;
|
||||||
}
|
}
|
||||||
|
@ -117,12 +118,13 @@ void *v4l2_m2m_buf_remove(struct v4l2_m2m_queue_ctx *q_ctx)
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&q_ctx->rdy_spinlock, flags);
|
spin_lock_irqsave(&q_ctx->rdy_spinlock, flags);
|
||||||
if (!list_empty(&q_ctx->rdy_queue)) {
|
if (list_empty(&q_ctx->rdy_queue)) {
|
||||||
b = list_entry(q_ctx->rdy_queue.next, struct v4l2_m2m_buffer,
|
spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags);
|
||||||
list);
|
return NULL;
|
||||||
list_del(&b->list);
|
|
||||||
q_ctx->num_rdy--;
|
|
||||||
}
|
}
|
||||||
|
b = list_entry(q_ctx->rdy_queue.next, struct v4l2_m2m_buffer, list);
|
||||||
|
list_del(&b->list);
|
||||||
|
q_ctx->num_rdy--;
|
||||||
spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags);
|
spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags);
|
||||||
|
|
||||||
return &b->vb;
|
return &b->vb;
|
||||||
|
|
Loading…
Reference in a new issue