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 @@ -871,6 +871,7 @@ static int uvc_ioctl_enum_input(struct file *file, void *fh, struct uvc_video_chain *chain = handle->chain; const struct uvc_entity *selector = chain->selector; struct uvc_entity *iterm = NULL; + bool found_pin = false; u32 index = input->index; int pin = 0; @@ -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)); -- 2.34.1