Re: [PATCH] uvc: fix missing check to determine if element is found in list

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

 



On Tue, 22 Mar 2022 15:10:21 +0200, Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> wrote:
> > > Fixes: d5e90b7a6cd1c ("[media] uvcvideo: Move to video_ioctl2")
> > > Signed-off-by: Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx>
> > > ---
> > >  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@xxxxxxxxxxxxxxxx>

I'm fine with those small changes, thank you.

--
Xiaomeng Tong



[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