mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xiaomeng Tong <xiam0nd.tong@gmail.com>
To: laurent.pinchart@ideasonboard.com
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	mchehab@kernel.org, ribalda@chromium.org, xiam0nd.tong@gmail.com
Subject: Re: [PATCH] uvc: fix missing check to determine if element is found in list
Date: Tue, 29 Mar 2022 13:09:25 +0800	[thread overview]
Message-ID: <20220329050925.15300-1-xiam0nd.tong@gmail.com> (raw)
In-Reply-To: <YjnKvQZot2wnljmW@pendragon.ideasonboard.com>

On Tue, 22 Mar 2022 15:10:21 +0200, Laurent Pinchart wrote:

> > > Fixes: d5e90b7a6cd1c ("[media] uvcvideo: Move to video_ioctl2")
> > > Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.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@ideasonboard.com>

Thank you, i have resend a Patch v2 with changes as you suggested, please check it.

--
Xiaomeng Tong

      parent reply	other threads:[~2022-03-29  5:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-19 10:22 Xiaomeng Tong
2022-03-22 12:40 ` Ricardo Ribalda
2022-03-22 13:10   ` Laurent Pinchart
2022-03-26  7:00     ` Xiaomeng Tong
2022-03-29  5:09     ` Xiaomeng Tong [this message]

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=20220329050925.15300-1-xiam0nd.tong@gmail.com \
    --to=xiam0nd.tong@gmail.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=ribalda@chromium.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®