media: ipu3-cio2: Fix mbus_code processing in cio2_subdev_set_fmt()

Message ID 20201230125550.GA14074@duo.ucw.cz (mailing list archive)
State Accepted, archived
Headers
Series media: ipu3-cio2: Fix mbus_code processing in cio2_subdev_set_fmt() |

Commit Message

Pavel Machek Dec. 30, 2020, 12:55 p.m. UTC
  Loop was useless as it would always exit on the first iteration. Fix
it with right condition. 

Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
Fixes: a86cf9b29e8b ("media: ipu3-cio2: Validate mbus format in setting subdev format")

index 36e354ecf71e..e8ea69d30bfd 100644
  

Comments

Laurent Pinchart Dec. 30, 2020, 9:20 p.m. UTC | #1
Hi Pavel,

Thank you for the patch.

On Wed, Dec 30, 2020 at 01:55:50PM +0100, Pavel Machek wrote:
> Loop was useless as it would always exit on the first iteration. Fix
> it with right condition. 
> 
> Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
> Fixes: a86cf9b29e8b ("media: ipu3-cio2: Validate mbus format in setting subdev format")

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

> index 36e354ecf71e..e8ea69d30bfd 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> @@ -1269,7 +1269,7 @@ static int cio2_subdev_set_fmt(struct v4l2_subdev *sd,
>  	fmt->format.code = formats[0].mbus_code;
>  
>  	for (i = 0; i < ARRAY_SIZE(formats); i++) {
> -		if (formats[i].mbus_code == fmt->format.code) {
> +		if (formats[i].mbus_code == mbus_code) {
>  			fmt->format.code = mbus_code;
>  			break;
>  		}
>
  
Sakari Ailus Jan. 2, 2021, 5:27 p.m. UTC | #2
On Wed, Dec 30, 2020 at 11:20:09PM +0200, Laurent Pinchart wrote:
> Hi Pavel,
> 
> Thank you for the patch.
> 
> On Wed, Dec 30, 2020 at 01:55:50PM +0100, Pavel Machek wrote:
> > Loop was useless as it would always exit on the first iteration. Fix
> > it with right condition. 
> > 
> > Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
> > Fixes: a86cf9b29e8b ("media: ipu3-cio2: Validate mbus format in setting subdev format")
> 
> Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Thanks!

As this should go to stable, I'm adding:

	Cc: stable@vger.kernel.org # v4.16 and up

> 
> > index 36e354ecf71e..e8ea69d30bfd 100644
> > --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> > +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> > @@ -1269,7 +1269,7 @@ static int cio2_subdev_set_fmt(struct v4l2_subdev *sd,
> >  	fmt->format.code = formats[0].mbus_code;
> >  
> >  	for (i = 0; i < ARRAY_SIZE(formats); i++) {
> > -		if (formats[i].mbus_code == fmt->format.code) {
> > +		if (formats[i].mbus_code == mbus_code) {
> >  			fmt->format.code = mbus_code;
> >  			break;
> >  		}
> > 
> 
> -- 
> Regards,
> 
> Laurent Pinchart
  

Patch

--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
@@ -1269,7 +1269,7 @@  static int cio2_subdev_set_fmt(struct v4l2_subdev *sd,
 	fmt->format.code = formats[0].mbus_code;
 
 	for (i = 0; i < ARRAY_SIZE(formats); i++) {
-		if (formats[i].mbus_code == fmt->format.code) {
+		if (formats[i].mbus_code == mbus_code) {
 			fmt->format.code = mbus_code;
 			break;
 		}