[media] drivers: media: platform: vivid: Fix possible null derefrence

Check for dev_fmt being null before derefrencing it, to assign it
to planes.

Found using Coccinelle.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
Tapasweni Pathak 2015-03-05 23:39:40 -03:00 committed by Mauro Carvalho Chehab
parent 64bf8049a2
commit 4eaa3a6cc4
1 changed files with 3 additions and 1 deletions

View File

@ -114,7 +114,7 @@ static int vid_out_buf_prepare(struct vb2_buffer *vb)
{ {
struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
unsigned long size; unsigned long size;
unsigned planes = dev->fmt_out->planes; unsigned planes;
unsigned p; unsigned p;
dprintk(dev, 1, "%s\n", __func__); dprintk(dev, 1, "%s\n", __func__);
@ -122,6 +122,8 @@ static int vid_out_buf_prepare(struct vb2_buffer *vb)
if (WARN_ON(NULL == dev->fmt_out)) if (WARN_ON(NULL == dev->fmt_out))
return -EINVAL; return -EINVAL;
planes = dev->fmt_out->planes;
if (dev->buf_prepare_error) { if (dev->buf_prepare_error) {
/* /*
* Error injection: test what happens if buf_prepare() returns * Error injection: test what happens if buf_prepare() returns