All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: linux-media@vger.kernel.org
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Sakari Ailus <sakari.ailus@iki.fi>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>
Subject: [PATCH 7/7] uvc_v4l2.c: avoid using iterator used outside loop
Date: Mon,  9 May 2022 11:15:53 +0200	[thread overview]
Message-ID: <20220509091553.2637089-8-hverkuil-cisco@xs4all.nl> (raw)
In-Reply-To: <20220509091553.2637089-1-hverkuil-cisco@xs4all.nl>

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@xs4all.nl>
---
 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


  parent reply	other threads:[~2022-05-09  9:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  9:15 [PATCH 0/7] Various smatch fixes Hans Verkuil
2022-05-09  9:15 ` [PATCH 1/7] v4l2-subdev.c: kvmalloc_array -> kvcalloc Hans Verkuil
2022-05-09 10:29   ` Laurent Pinchart
2022-05-09  9:15 ` [PATCH 2/7] v4l2-ctls-core.c: " Hans Verkuil
2022-05-09 10:29   ` Laurent Pinchart
2022-05-09  9:15 ` [PATCH 3/7] videobuf2-dma-sg.c: " Hans Verkuil
2022-05-09 10:29   ` Laurent Pinchart
2022-05-09  9:15 ` [PATCH 4/7] cx25821: request_irq -> devm_request_irq Hans Verkuil
2022-05-09  9:15 ` [PATCH 5/7] ccs-core.c: fix failure to call clk_disable_unprepare Hans Verkuil
2022-05-09  9:15 ` [PATCH 6/7] s5k6a3: add missing clk_disable_unprepare Hans Verkuil
2022-05-09  9:15 ` Hans Verkuil [this message]
2022-05-09 10:04   ` [PATCH 7/7] uvc_v4l2.c: avoid using iterator used outside loop Sakari Ailus
2022-05-09 10:09   ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220509091553.2637089-8-hverkuil-cisco@xs4all.nl \
    --to=hverkuil-cisco@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.