From: "Bjørn Mork" <bjorn@mork.no>
To: Ming Lei <tom.leiming@gmail.com>
Cc: netdev@vger.kernel.org, linux-usb@vger.kernel.org,
"Marius Bjørnstad Kotsbak" <marius.kotsbak@gmail.com>
Subject: Re: [PATCH net] net: qmi_wwan: fix Oops while disconnecting
Date: Fri, 22 Jun 2012 15:42:26 +0200 [thread overview]
Message-ID: <87mx3vlayl.fsf@nemi.mork.no> (raw)
In-Reply-To: <CACVXFVPkC8NtvOzTsOyNcftZy60fDjtEkV_Da1Z32iYpHFHcUw@mail.gmail.com> (Ming Lei's message of "Fri, 22 Jun 2012 20:45:12 +0800")
Ming Lei <tom.leiming@gmail.com> writes:
> On Fri, Jun 22, 2012 at 5:11 PM, Bjørn Mork <bjorn@mork.no> wrote:
>> usbnet_disconnect() will set intfdata to NULL before calling
>> the minidriver unbind function. The cdc_wdm subdriver cannot
>> know that it is disconnecting until the qmi_wwan unbind
>> function has called its disconnect function. This means that
>> we must be able to support the cdc_wdm subdriver operating
>> normally while usbnet_disconnect() is running, and in
>> particular that intfdata may be NULL.
>>
>> The only place this matters is in qmi_wwan_cdc_wdm_manage_power
>> which is called from cdc_wdm. Simply testing for NULL
>> intfdata there is sufficient to allow it to continue working
>> at all times.
>>
>> Fixes this Oops where a cdc-wdm device was closed while the
>> USB device was disconnecting, causing wdm_release to call
>> qmi_wwan_cdc_wdm_manage_power after intfdata was set to
>> NULL by usbnet_disconnect:
>
> In fact, it should be a general problem in usbnet, there are races
> between usbnet_disconnect and .open/.close. Considered that
> unregister_netdev, which will sync with .open/.close, is called in
> usbnet_disconnect, the simplest fix is to move usb_set_intfdata(NULL)
> after unregister_netdev.
Is there really a race there? The usbnet .open/.close don't use the
intfdata, do they? I looked briefly through usbnet for related
potentional problems while fixing this in qmi_wwan, but could only find
suspend/resume. Which I believe are protected against running on
disconnect.
So I think usbnet in general is OK.
> Considered that usb_set_intfdata(NULL) will be called after
> executing .disconnect in unbind path, it can be removed simply.
>
> So how about the below?
>
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index e92c057..2eb9e1e 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -1286,7 +1286,6 @@ void usbnet_disconnect (struct usb_interface *intf)
> struct net_device *net;
>
> dev = usb_get_intfdata(intf);
> - usb_set_intfdata(intf, NULL);
> if (!dev)
> return;
I believe that call is there to prevent disconnect from running twice
for the common two-interface CDC ethernet model, like e.g. cdc_ether.
So I don't think it can be removed. Not without touching the
minidrivers depending on that behaviour, anyway.
Bjørn
next prev parent reply other threads:[~2012-06-22 13:43 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-22 9:11 [PATCH net] net: qmi_wwan: fix Oops while disconnecting Bjørn Mork
[not found] ` <1340356279-3124-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2012-06-22 12:45 ` Ming Lei
2012-06-22 13:42 ` Bjørn Mork [this message]
2012-06-22 15:09 ` Ming Lei
[not found] ` <CACVXFVOQ3Uh50iJxboD-7=+J55MAW8Wjt3iY0WahauO2PrxT4w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-22 16:18 ` Bjørn Mork
[not found] ` <877guzl3qz.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2012-06-22 16:52 ` Ming Lei
[not found] ` <CACVXFVNCAsM5NihpAFLU5rGo5ynr3=XU5gw7nM5Fi2mrrX+hKA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-22 17:31 ` Bjørn Mork
2012-06-23 3:32 ` Ming Lei
2012-06-23 3:39 ` Ming Lei
[not found] ` <CACVXFVMJSrLjOyKUnZWr3CY2HJT6Wfm6AugZOhSCRUubV0hNMQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-23 8:45 ` Bjørn Mork
2012-06-23 14:55 ` Ming Lei
2012-06-23 15:32 ` Bjørn Mork
[not found] ` <87hau2hwna.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2012-06-23 20:55 ` Oliver Neukum
[not found] ` <201206232255.08319.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2012-06-24 9:34 ` Bjørn Mork
2012-06-24 12:13 ` Oliver Neukum
2012-06-24 17:47 ` Bjørn Mork
2012-06-25 3:37 ` Ming Lei
2012-06-25 6:15 ` Oliver Neukum
2012-06-25 7:15 ` Ming Lei
[not found] ` <CACVXFVNUv6w5OjSZdQDbcLEPpDU5vO_Nmarm+fAfh0RkkL_hdg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-25 12:10 ` Oliver Neukum
2012-06-26 7:23 ` Ming Lei
2012-06-28 8:35 ` Oliver Neukum
[not found] ` <201206281035.19964.oneukum-l3A5Bk7waGM@public.gmane.org>
2012-06-28 8:55 ` Bjørn Mork
2012-06-28 9:11 ` Ming Lei
[not found] ` <CACVXFVN3wJ3NWxSGj-yWCgtDE_sgJT5CZYHwYUWk1MxkphcsTg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-25 7:24 ` Bjørn Mork
2012-06-25 8:08 ` Ming Lei
[not found] ` <CACVXFVOPjFSS6Sv6AUCSAs4nywR045QhjYAbN8g6U3adsUbujw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-25 8:27 ` Bjørn Mork
2012-06-28 8:36 ` Bjørn Mork
[not found] ` <87lij7de8u.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2012-06-28 8:40 ` Oliver Neukum
[not found] ` <201206281040.55402.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2012-06-28 23:54 ` David Miller
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=87mx3vlayl.fsf@nemi.mork.no \
--to=bjorn@mork.no \
--cc=linux-usb@vger.kernel.org \
--cc=marius.kotsbak@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=tom.leiming@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.