Re: [PATCH 1/2] media: imx7-media-csi: don't store a floating pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Oi Mauro,
On Tue 19 Feb 2019 at 13:24, Mauro Carvalho Chehab wrote:
if imx7_csi_try_fmt() fails, outcc variable won't be
initialized and csi->cc[IMX7_CSI_PAD_SRC] would be pointing
to a random location.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@xxxxxxxxxx>

Thanks for this, looks good.
Reviewed-by: Rui Miguel Silva <rmfrfs@xxxxxxxxx>

---
Cheers,
	Rui

---
drivers/staging/media/imx/imx7-media-csi.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c
index d775e259fece..0b1788d79ce9 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -980,10 +980,10 @@ static int imx7_csi_get_fmt(struct v4l2_subdev *sd,
 	return ret;
 }
-static void imx7_csi_try_fmt(struct imx7_csi *csi,
-			     struct v4l2_subdev_pad_config *cfg,
-			     struct v4l2_subdev_format *sdformat,
-			     const struct imx_media_pixfmt **cc)
+static int imx7_csi_try_fmt(struct imx7_csi *csi,
+			    struct v4l2_subdev_pad_config *cfg,
+			    struct v4l2_subdev_format *sdformat,
+			    const struct imx_media_pixfmt **cc)
 {
 	const struct imx_media_pixfmt *in_cc;
 	struct v4l2_mbus_framefmt *in_fmt;
@@ -992,7 +992,7 @@ static void imx7_csi_try_fmt(struct imx7_csi *csi,
 	in_fmt = imx7_csi_get_format(csi, cfg, IMX7_CSI_PAD_SINK,
 				     sdformat->which);
 	if (!in_fmt)
-		return;
+		return -EINVAL;
switch (sdformat->pad) {
 	case IMX7_CSI_PAD_SRC:
@@ -1023,8 +1023,10 @@ static void imx7_csi_try_fmt(struct imx7_csi *csi,
 						   false);
 		break;
 	default:
+		return -EINVAL;
 		break;
 	}
+	return 0;
 }
static int imx7_csi_set_fmt(struct v4l2_subdev *sd, @@ -1067,8 +1069,10 @@ static int imx7_csi_set_fmt(struct v4l2_subdev *sd,
 		format.pad = IMX7_CSI_PAD_SRC;
 		format.which = sdformat->which;
 		format.format = sdformat->format;
-		imx7_csi_try_fmt(csi, cfg, &format, &outcc);
-
+		if (imx7_csi_try_fmt(csi, cfg, &format, &outcc)) {
+			ret = -EINVAL;
+			goto out_unlock;
+		}
outfmt = imx7_csi_get_format(csi, cfg, IMX7_CSI_PAD_SRC,
 					     sdformat->which);
 		*outfmt = format.format;

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux