linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
From: Himadri Pandya <himadrispandya@gmail.com>
To: Oliver Neukum <oneukum@suse.com>
Cc: petkan@nucleusys.com, pankaj.laxminarayan.bharadiya@intel.com,
	USB list <linux-usb@vger.kernel.org>,
	yuehaibing@huawei.com, LKML <linux-kernel@vger.kernel.org>,
	ogiannou@gmail.com, netdev <netdev@vger.kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-kernel-mentees@lists.linuxfoundation.org,
	David Miller <davem@davemloft.net>,
	Kees Cook <keescook@chromium.org>
Subject: Re: [Linux-kernel-mentees] [PATCH 3/4] net: usb: rtl8150: use usb_control_msg_recv() and usb_control_msg_send()
Date: Wed, 23 Sep 2020 19:36:10 +0530	[thread overview]
Message-ID: <CAOY-YVkHycXqem_Xr6nQLgKEunk3MNc7dBtZ=5Aym4Y06vs9xQ@mail.gmail.com> (raw)
In-Reply-To: <1600856557.26851.6.camel@suse.com>

On Wed, Sep 23, 2020 at 3:52 PM Oliver Neukum <oneukum@suse.com> wrote:
>
> Am Mittwoch, den 23.09.2020, 14:35 +0530 schrieb Himadri Pandya:
>
> Hi,
>
> > Many usage of usb_control_msg() do not have proper error check on return
> > value leaving scope for bugs on short reads. New usb_control_msg_recv()
> > and usb_control_msg_send() nicely wraps usb_control_msg() with proper
> > error check. Hence use the wrappers instead of calling usb_control_msg()
> > directly.
> >
> > Signed-off-by: Himadri Pandya <himadrispandya@gmail.com>
> Nacked-by: Oliver Neukum <oneukum@suse.com>
>
> > ---
> >  drivers/net/usb/rtl8150.c | 32 ++++++--------------------------
> >  1 file changed, 6 insertions(+), 26 deletions(-)
> >
> > diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
> > index 733f120c852b..e3002b675921 100644
> > --- a/drivers/net/usb/rtl8150.c
> > +++ b/drivers/net/usb/rtl8150.c
> > @@ -152,36 +152,16 @@ static const char driver_name [] = "rtl8150";
> >  */
> >  static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)
> >  {
> > -     void *buf;
> > -     int ret;
> > -
> > -     buf = kmalloc(size, GFP_NOIO);
>
> GFP_NOIO is used here for a reason. You need to use this helper
> while in contexts of error recovery and runtime PM.
>

Understood. Apologies for proposing such a stupid change.

> > -     if (!buf)
> > -             return -ENOMEM;
> > -
> > -     ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
> > -                           RTL8150_REQ_GET_REGS, RTL8150_REQT_READ,
> > -                           indx, 0, buf, size, 500);
> > -     if (ret > 0 && ret <= size)
> > -             memcpy(data, buf, ret);
> > -     kfree(buf);
> > -     return ret;
> > +     return usb_control_msg_recv(dev->udev, 0, RTL8150_REQ_GET_REGS,
> > +                                 RTL8150_REQT_READ, indx, 0, data,
> > +                                 size, 500);
>
> This internally uses kmemdup() with GFP_KERNEL.
> You cannot make this change. The API does not support it.
> I am afraid we will have to change the API first, before more
> such changes are done.
>
> I would suggest dropping the whole series for now.

Okay. Thanks for the review.

Regards,
Himadri

>
>         Regards
>                 Oliver
>
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  reply	other threads:[~2020-09-23 14:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23  9:05 [Linux-kernel-mentees] [PATCH 0/4] net: usb: avoid using usb_control_msg() directly Himadri Pandya
2020-09-23  9:05 ` [Linux-kernel-mentees] [PATCH 1/4] net: usbnet: use usb_control_msg_recv() and usb_control_msg_send() Himadri Pandya
2020-09-23 10:24   ` Greg KH
2020-09-23 14:08     ` Himadri Pandya
2020-09-23  9:05 ` [Linux-kernel-mentees] [PATCH 2/4] net: sierra_net: use usb_control_msg_recv() Himadri Pandya
2020-09-23  9:05 ` [Linux-kernel-mentees] [PATCH 3/4] net: usb: rtl8150: use usb_control_msg_recv() and usb_control_msg_send() Himadri Pandya
2020-09-23 10:22   ` Oliver Neukum
2020-09-23 14:06     ` Himadri Pandya [this message]
2020-09-23 14:20       ` Oliver Neukum
2020-09-23 14:32         ` Himadri Pandya
2020-09-24 11:13           ` Oliver Neukum
2020-09-25 11:23             ` Himadri Pandya
2020-09-23 14:48     ` Petko Manolov
2020-09-24 11:09       ` Oliver Neukum
2020-09-24 15:40         ` Petko Manolov
2020-09-24 16:01           ` Greg KH
2020-09-23  9:05 ` [Linux-kernel-mentees] [PATCH 4/4] net: rndis_host: " Himadri Pandya
2020-09-23 10:22   ` Greg KH
2020-09-23 14:14     ` Himadri Pandya
2020-09-23 10:23 ` [Linux-kernel-mentees] [PATCH 0/4] net: usb: avoid using usb_control_msg() directly Greg KH

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='CAOY-YVkHycXqem_Xr6nQLgKEunk3MNc7dBtZ=5Aym4Y06vs9xQ@mail.gmail.com' \
    --to=himadrispandya@gmail.com \
    --cc=davem@davemloft.net \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ogiannou@gmail.com \
    --cc=oneukum@suse.com \
    --cc=pankaj.laxminarayan.bharadiya@intel.com \
    --cc=petkan@nucleusys.com \
    --cc=yuehaibing@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).