diff options
author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2022-07-01 15:15:59 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2022-07-15 16:21:53 +0200 |
commit | f076057f0107c3ef890bfad8d6658387504e7f11 (patch) | |
tree | f85fddbc5ad188603fddaf3296868774d669bc15 /drivers/media/platform/st | |
parent | media: subdev: Add v4l2_subdev_call_state_try() macro (diff) | |
download | linux-f076057f0107c3ef890bfad8d6658387504e7f11.tar.xz linux-f076057f0107c3ef890bfad8d6658387504e7f11.zip |
media: stm32: dcmi: Fix subdev op call with uninitialized state
stm32-dcmi calls its source subdev with v4l2_subdev_call() using a
v4l2_subdev_state constructed on stack. This means that init_cfg is
never called for that state, and a source subdev that depends on the
init_cfg call may break.
A new macro has been added for this particular purpose, which properly
initializes the state, so let's use v4l2_subdev_call_state_try() here.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/platform/st')
-rw-r--r-- | drivers/media/platform/st/stm32/stm32-dcmi.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/drivers/media/platform/st/stm32/stm32-dcmi.c b/drivers/media/platform/st/stm32/stm32-dcmi.c index d0e5f22a6192..9b14a113083f 100644 --- a/drivers/media/platform/st/stm32/stm32-dcmi.c +++ b/drivers/media/platform/st/stm32/stm32-dcmi.c @@ -998,10 +998,6 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, const struct dcmi_format *sd_fmt; struct dcmi_framesize sd_fsize; struct v4l2_pix_format *pix = &f->fmt.pix; - struct v4l2_subdev_pad_config pad_cfg; - struct v4l2_subdev_state pad_state = { - .pads = &pad_cfg - }; struct v4l2_subdev_format format = { .which = V4L2_SUBDEV_FORMAT_TRY, }; @@ -1036,8 +1032,7 @@ static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, } v4l2_fill_mbus_format(&format.format, pix, sd_fmt->mbus_code); - ret = v4l2_subdev_call(dcmi->source, pad, set_fmt, - &pad_state, &format); + ret = v4l2_subdev_call_state_try(dcmi->source, pad, set_fmt, &format); if (ret < 0) return ret; @@ -1186,10 +1181,6 @@ static int dcmi_set_sensor_format(struct stm32_dcmi *dcmi, struct v4l2_subdev_format format = { .which = V4L2_SUBDEV_FORMAT_TRY, }; - struct v4l2_subdev_pad_config pad_cfg; - struct v4l2_subdev_state pad_state = { - .pads = &pad_cfg - }; int ret; sd_fmt = find_format_by_fourcc(dcmi, pix->pixelformat); @@ -1202,8 +1193,7 @@ static int dcmi_set_sensor_format(struct stm32_dcmi *dcmi, } v4l2_fill_mbus_format(&format.format, pix, sd_fmt->mbus_code); - ret = v4l2_subdev_call(dcmi->source, pad, set_fmt, - &pad_state, &format); + ret = v4l2_subdev_call_state_try(dcmi->source, pad, set_fmt, &format); if (ret < 0) return ret; |