Re: [PATCH] usb: gadget: fix check in sync read from ep in gadgetfs

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

 



On Sun, Jul 10, 2016 at 11:25:17AM +0300, Binyamin Sharet wrote:
> Hi,
> 
> Could someone please advise whether I should also open a bug in
> bugzilla for this thing? or if there anything else I'm missing?
> 

It is not necessary, the related maintainers will comment or
accept it.

Peter
> This is the first time that I deal with kernel
> modification/development, and I'm not sure about the process in
> general and in the USB develepor community.
> 
> Thanks,
> Binyamin
> 
> On Thu, Jul 7, 2016 at 10:22 PM, Binyamin Sharet <s.binyamin@xxxxxxxxx> wrote:
> > When reading synchronously from a non-zero endpoint, gadgetfs will
> > return -EFAULT even if the read succeeds, due to a bad check of the
> > copy_to_iter() return value.
> >
> > This fix compares the return value of copy_to_iter to the amount of
> > bytes that was passed, and only fails if they are not the same.
> >
> > Signed-off-by: Binyamin Sharet <s.binyamin@xxxxxxxxx>
> > ---
> >  drivers/usb/gadget/legacy/inode.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
> > index aa3707b..8560f2f 100644
> > --- a/drivers/usb/gadget/legacy/inode.c
> > +++ b/drivers/usb/gadget/legacy/inode.c
> > @@ -606,7 +606,7 @@ ep_read_iter(struct kiocb *iocb, struct iov_iter *to)
> >         }
> >         if (is_sync_kiocb(iocb)) {
> >                 value = ep_io(epdata, buf, len);
> > -               if (value >= 0 && copy_to_iter(buf, value, to))
> > +               if (value >= 0 && (copy_to_iter(buf, value, to) != value))
> >                         value = -EFAULT;
> >         } else {
> >                 struct kiocb_priv *priv = kzalloc(sizeof *priv, GFP_KERNEL);
> > --
> > 2.7.4
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux