[media] s3c-camif: Check if fmt is NULL before use
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 28 Apr 2015 15:12:09 +0000 (12:12 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 30 Apr 2015 16:38:36 +0000 (13:38 -0300)
As reported by smatch:
drivers/media/platform/s3c-camif/camif-capture.c:463 queue_setup() warn: variable dereferenced before check 'fmt' (see line 460)

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/s3c-camif/camif-capture.c

index db4d7d23beb9e01d38982234b1ba68044ad7b702..76e6289a5612d72d84ca404264ca87878f0f7188 100644 (file)
@@ -449,19 +449,22 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *pfmt,
        struct camif_vp *vp = vb2_get_drv_priv(vq);
        struct camif_dev *camif = vp->camif;
        struct camif_frame *frame = &vp->out_frame;
-       const struct camif_fmt *fmt = vp->out_fmt;
+       const struct camif_fmt *fmt;
        unsigned int size;
 
        if (pfmt) {
                pix = &pfmt->fmt.pix;
                fmt = s3c_camif_find_format(vp, &pix->pixelformat, -1);
+               if (fmt == NULL)
+                       return -EINVAL;
                size = (pix->width * pix->height * fmt->depth) / 8;
        } else {
+               fmt = vp->out_fmt;
+               if (fmt == NULL)
+                       return -EINVAL;
                size = (frame->f_width * frame->f_height * fmt->depth) / 8;
        }
 
-       if (fmt == NULL)
-               return -EINVAL;
        *num_planes = 1;
 
        if (pix)