media: imx-mipi-csis: Check csis_fmt validity before use
PATCH v2 1/1 media: imx-mipi-csis: Check csis_fmt validity before use
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.
---
Cc: Fabio Estevam <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Philipp Zabel <[email protected]>
Cc: Rui Miguel Silva <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
V2: Add blank line
--- drivers/media/platform/nxp/imx-mipi-csis.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/nxp/imx-mipi-csis.c +3 -0
@@ -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 -EINVAL ; + fd->type =V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL ; fd->num_entries =1 ;
Signature · 1 line
2.39.1
Laurent Pinchart
maintainerHi Marek,
Quoted 30 lines · Marek Vasut
The
find_csis_format()may return NULL in case supported format is not found, check the return value offind_csis_format()before using the result to avoid NULL pointer dereference.Reviewed-by Laurent Pinchart <[email protected]>Fixes 11927d0fd0d0 ("media: imx-mipi-csis: Use V4L2 subdev active state")Signed-off-by Marek Vasut <[email protected]>---
Cc: Fabio Estevam <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Philipp Zabel <[email protected]>
Cc: Rui Miguel Silva <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
V2: Add blank line--- drivers/media/platform/nxp/imx-mipi-csis.c | 3 +++ 1 file changed, 3 insertions(+)drivers/media/platform/nxp/imx-mipi-csis.c +0
-0
drivers/media/platform/nxp/imx-mipi-csis.c static int mipi_csis_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, · line 1113
Quoted 5 lines
drivers/media/platform/nxp/imx-mipi-csis.c +2
-0@@ -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 -EINVAL ;
I miss this when reviewing v1, would -EPIPE be a better error code ? Essentially, this error occurs when trying to start a pipeline where the sensor has been configured to produce a format not supported by the CSI-2 receiver. -EINVAL being used everywhere, it makes it more difficult for users to figure out where the failure may come from. We already use -EPIPE in many places when validating the pipeline, so I think it would be an appropriate option here.
If you're fine with this there's no need to send a v3, I'll update the error code in the pull request.
Quoted 4 lines
drivers/media/platform/nxp/imx-mipi-csis.c +1
-0+ fd->type =V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL ; fd->num_entries =1 ;
Signature · 3 lines
Regards, Laurent Pinchart