From: Greg KH <gregkh@linuxfoundation.org>
To: kvaradarajan <Kiruthika.Varadarajan@harman.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] USB/Gadget: Fix race between gether_disconnect and rx_submit
Date: Wed, 19 Jun 2019 16:59:26 +0200 [thread overview]
Message-ID: <20190619145926.GA18985@kroah.com> (raw)
In-Reply-To: <1560926470-15092-1-git-send-email-Kiruthika.Varadarajan@harman.com>
On Wed, Jun 19, 2019 at 06:41:10AM +0000, kvaradarajan wrote:
> On spin lock release in rx_submit, gether_disconnect get
> a chance to run, it makes port_usb NULL, rx_submit access
> NULL port USB, hence null pointer crash.
>
> Fixed by releasing the lock in rx_submit after port_usb
> is used.
Meta-comments about the patch information...
Why is this indented? Please keep comments all the way to the left and
wrap the columns at 72.
> Signed-off-by: KVaradarajan <Kiruthika.Varadarajan@harman.com>
I need a "legal name" here, I don't think you sign documents that way.
It also needs to match the From: line of your email.
> ---
> drivers/usb/gadget/function/u_ether.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
> index 737bd77..76cf1e4 100644
> --- a/drivers/usb/gadget/function/u_ether.c
> +++ b/drivers/usb/gadget/function/u_ether.c
> @@ -186,11 +186,11 @@ static void defer_kevent(struct eth_dev *dev, int flag)
> out = dev->port_usb->out_ep;
> else
> out = NULL;
> - spin_unlock_irqrestore(&dev->lock, flags);
>
> - if (!out)
> + if (!out) {
> + spin_unlock_irqrestore(&dev->lock, flags);
> return -ENOTCONN;
> -
> + }
>
> /* Padding up to RX_EXTRA handles minor disagreements with host.
> * Normally we use the USB "terminate on short read" convention;
> @@ -215,6 +215,7 @@ static void defer_kevent(struct eth_dev *dev, int flag)
> if (dev->port_usb->is_fixed)
> size = max_t(size_t, size, dev->port_usb->fixed_out_len);
>
> + spin_unlock_irqrestore(&dev->lock, flags);
Patch looks sane to me. I'll let Felipe do the real review after you
resend based on the information above.
thanks,
greg k-h
next prev parent reply other threads:[~2019-06-19 14:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-19 6:41 [PATCH] USB/Gadget: Fix race between gether_disconnect and rx_submit kvaradarajan
2019-06-19 14:59 ` Greg KH [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-06-20 8:55 kvaradarajan
2019-10-22 6:20 ` Felipe Balbi
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=20190619145926.GA18985@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=Kiruthika.Varadarajan@harman.com \
--cc=linux-usb@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).