Re: [PATCH 7/7] uvc_v4l2.c: avoid using iterator used outside loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Hans,

Thanks for the set.

On Mon, May 09, 2022 at 11:15:53AM +0200, Hans Verkuil wrote:
> Fixes these two smatch warnings:
> 
> drivers/media/usb/uvc/uvc_v4l2.c:885 uvc_ioctl_enum_input() warn: iterator used outside loop: 'iterm'
> drivers/media/usb/uvc/uvc_v4l2.c:896 uvc_ioctl_enum_input() warn: iterator used outside loop: 'iterm'
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
> ---
>  drivers/media/usb/uvc/uvc_v4l2.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
> index 711556d13d03..ff3f04af4e21 100644
> --- a/drivers/media/usb/uvc/uvc_v4l2.c
> +++ b/drivers/media/usb/uvc/uvc_v4l2.c

...

> @@ -879,21 +880,25 @@ static int uvc_ioctl_enum_input(struct file *file, void *fh,
>  		if (index != 0)
>  			return -EINVAL;
>  		list_for_each_entry(iterm, &chain->entities, chain) {
> -			if (UVC_ENTITY_IS_ITERM(iterm))
> +			if (UVC_ENTITY_IS_ITERM(iterm)) {
> +				pin = iterm->id;
> +				found_pin = true;
>  				break;
> +			}
>  		}
> -		pin = iterm->id;
>  	} else if (index < selector->bNrInPins) {
>  		pin = selector->baSourceID[index];
>  		list_for_each_entry(iterm, &chain->entities, chain) {
>  			if (!UVC_ENTITY_IS_ITERM(iterm))
>  				continue;
> -			if (iterm->id == pin)
> +			if (iterm->id == pin) {
> +				found_pin = true;
>  				break;
> +			}
>  		}
>  	}
>  
> -	if (iterm == NULL || iterm->id != pin)
> +	if (!found_pin)
>  		return -EINVAL;
>  
>  	memset(input, 0, sizeof(*input));

iterm is used a few lines below, too, so this patch doesn't remove its use
outside the loop. Which btw. I don't think is a problem at all. Doing that
is relatively common IMO.

For the rest of the set:

Acked-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>

-- 
Kind regards,

Sakari Ailus



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux