diff mbox series

[1/6] media: saa6752hs: Don't set format in sub-device state

Message ID 20231207120912.270716-2-sakari.ailus@linux.intel.com
State Accepted
Commit c692696fc51c5acee555b94d391d328510b557c8
Headers show
Series Old non-MC-aware drivers have no sub-device state | expand

Commit Message

Sakari Ailus Dec. 7, 2023, 12:09 p.m. UTC
For the purpose of setting old non-pad based sub-device try format as a
basis for VIDIOC_TRY_FMT implementation, there is no need to set the
format in the sub-device state. Drop the assignment to the state, which
would result in a NULL pointer dereference.

Fixes: fd17e3a9a788 ("media: i2c: Use accessors for pad config 'try_*' fields")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/i2c/saa6752hs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Laurent Pinchart Dec. 7, 2023, 12:44 p.m. UTC | #1
Hi Sakari,

Thank you for the patch.

On Thu, Dec 07, 2023 at 02:09:07PM +0200, Sakari Ailus wrote:
> For the purpose of setting old non-pad based sub-device try format as a
> basis for VIDIOC_TRY_FMT implementation, there is no need to set the
> format in the sub-device state. Drop the assignment to the state, which
> would result in a NULL pointer dereference.
> 
> Fixes: fd17e3a9a788 ("media: i2c: Use accessors for pad config 'try_*' fields")
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> ---
>  drivers/media/i2c/saa6752hs.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/media/i2c/saa6752hs.c b/drivers/media/i2c/saa6752hs.c
> index 51b62a97946a..897eaa669b86 100644
> --- a/drivers/media/i2c/saa6752hs.c
> +++ b/drivers/media/i2c/saa6752hs.c
> @@ -594,10 +594,8 @@ static int saa6752hs_set_fmt(struct v4l2_subdev *sd,
>  	f->field = V4L2_FIELD_INTERLACED;
>  	f->colorspace = V4L2_COLORSPACE_SMPTE170M;
>  
> -	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
> -		*v4l2_subdev_state_get_format(sd_state, 0) = *f;
> +	if (format->which == V4L2_SUBDEV_FORMAT_TRY)
>  		return 0;
> -	}
>  
>  	/*
>  	  FIXME: translate and round width/height into EMPRESS
diff mbox series

Patch

diff --git a/drivers/media/i2c/saa6752hs.c b/drivers/media/i2c/saa6752hs.c
index 51b62a97946a..897eaa669b86 100644
--- a/drivers/media/i2c/saa6752hs.c
+++ b/drivers/media/i2c/saa6752hs.c
@@ -594,10 +594,8 @@  static int saa6752hs_set_fmt(struct v4l2_subdev *sd,
 	f->field = V4L2_FIELD_INTERLACED;
 	f->colorspace = V4L2_COLORSPACE_SMPTE170M;
 
-	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-		*v4l2_subdev_state_get_format(sd_state, 0) = *f;
+	if (format->which == V4L2_SUBDEV_FORMAT_TRY)
 		return 0;
-	}
 
 	/*
 	  FIXME: translate and round width/height into EMPRESS