[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220326070049.10055-1-xiam0nd.tong@gmail.com>
Date: Sat, 26 Mar 2022 15:00:49 +0800
From: Xiaomeng Tong <xiam0nd.tong@...il.com>
To: laurent.pinchart@...asonboard.com
Cc: linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
mchehab@...nel.org, ribalda@...omium.org, xiam0nd.tong@...il.com
Subject: Re: [PATCH] uvc: fix missing check to determine if element is found in list
On Tue, 22 Mar 2022 15:10:21 +0200, Laurent Pinchart <laurent.pinchart@...asonboard.com> wrote:
> > > Fixes: d5e90b7a6cd1c ("[media] uvcvideo: Move to video_ioctl2")
> > > Signed-off-by: Xiaomeng Tong <xiam0nd.tong@...il.com>
> > > ---
> > > drivers/media/usb/uvc/uvc_v4l2.c | 20 +++++++++++++-------
> > > 1 file changed, 13 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
> > > index 711556d13d03..e7cdc01ad277 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;
> > > + struct uvc_entity *it;
> > > u32 index = input->index;
> > > int pin = 0;
> > >
> > > @@ -878,22 +879,27 @@ static int uvc_ioctl_enum_input(struct file *file, void *fh,
> > > (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) {
> > > if (index != 0)
> > > return -EINVAL;
> > > - list_for_each_entry(iterm, &chain->entities, chain) {
> > > - if (UVC_ENTITY_IS_ITERM(iterm))
> > > + list_for_each_entry(it, &chain->entities, chain) {
> > > + if (UVC_ENTITY_IS_ITERM(it)) {
> > > + iterm = it;
> > > break;
> > > + }
> > > }
> > > - pin = iterm->id;
> > > + if (iterm)
> > > + pin = iterm->id;
>
> You can drop this, pin is not used anymore in the rest of the function.
>
> > > } else if (index < selector->bNrInPins) {
> > > pin = selector->baSourceID[index];
> > > - list_for_each_entry(iterm, &chain->entities, chain) {
> > > - if (!UVC_ENTITY_IS_ITERM(iterm))
> > > + list_for_each_entry(it, &chain->entities, chain) {
> > > + if (!UVC_ENTITY_IS_ITERM(it))
> > > continue;
> > > - if (iterm->id == pin)
> > > + if (it->id == pin) {
>
> And here you could use
> if (it->id == selector->baSourceID[index]) {
>
> and drop the local pin variable.
>
> If you're fine with those small changes I can handle them when applying
> the patch to my tree.
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@...asonboard.com>
I'm fine with those small changes, thank you.
--
Xiaomeng Tong
Powered by blists - more mailing lists