media: imx7-media-csi: don't store a floating pointer
authorRui Miguel Silva <rui.silva@linaro.org>
Fri, 22 Feb 2019 10:17:10 +0000 (05:17 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 19 Mar 2019 17:43:52 +0000 (13:43 -0400)
if imx7_csi_try_fmt() fails, cc variable won't be
initialized and csi->cc[sdformat->pad] would be pointing
to a random location.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/staging/media/imx/imx7-media-csi.c

index 1ba62fcdcae8d6d38add9e49a85ef1b152f2caf7..18eb5d3ecf102ad5bca3f84379f1c290d2929a92 100644 (file)
@@ -1051,7 +1051,9 @@ static int imx7_csi_set_fmt(struct v4l2_subdev *sd,
                goto out_unlock;
        }
 
-       imx7_csi_try_fmt(csi, cfg, sdformat, &cc);
+       ret = imx7_csi_try_fmt(csi, cfg, sdformat, &cc);
+       if (ret < 0)
+               goto out_unlock;
 
        fmt = imx7_csi_get_format(csi, cfg, sdformat->pad, sdformat->which);
        if (!fmt) {