lkml.org 
[lkml]   [2022]   [Mar]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] uvc: fix missing check to determine if element is found in list
Date
On Tue, 22 Mar 2022 15:10:21 +0200, Laurent Pinchart <laurent.pinchart@ideasonboard.com> 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>

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

--
Xiaomeng Tong

\
 
 \ /
  Last update: 2022-03-26 08:01    [W:0.080 / U:25.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site