[PATCH v3] media: imx-mipi-csis: Check csis_fmt validity before use
Marek Vasut
marex at denx.de
Wed Feb 15 17:44:01 PST 2023
The find_csis_format() may return NULL in case supported format is not
found, check the return value of find_csis_format() before using the
result to avoid NULL pointer dereference.
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Fixes: 11927d0fd0d0 ("media: imx-mipi-csis: Use V4L2 subdev active state")
Signed-off-by: Marek Vasut <marex at denx.de>
---
Cc: Fabio Estevam <festevam at gmail.com>
Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Cc: Mauro Carvalho Chehab <mchehab at kernel.org>
Cc: NXP Linux Team <linux-imx at nxp.com>
Cc: Pengutronix Kernel Team <kernel at pengutronix.de>
Cc: Philipp Zabel <p.zabel at pengutronix.de>
Cc: Rui Miguel Silva <rmfrfs at gmail.com>
Cc: Sascha Hauer <s.hauer at pengutronix.de>
Cc: Shawn Guo <shawnguo at kernel.org>
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-media at vger.kernel.org
---
V2: Add blank line
V3: Return -EPIPE
---
drivers/media/platform/nxp/imx-mipi-csis.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
index e99633565463e..be2768a479951 100644
--- a/drivers/media/platform/nxp/imx-mipi-csis.c
+++ b/drivers/media/platform/nxp/imx-mipi-csis.c
@@ -1109,6 +1109,9 @@ static int mipi_csis_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
csis_fmt = find_csis_format(fmt->code);
v4l2_subdev_unlock_state(state);
+ if (!csis_fmt)
+ return -EPIPE;
+
fd->type = V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL;
fd->num_entries = 1;
--
2.39.1
More information about the linux-arm-kernel
mailing list