Commit 2ed13588 authored by Bjørn Mork's avatar Bjørn Mork Committed by Greg Kroah-Hartman

cdc_ncm: do not call usbnet_link_change from cdc_ncm_bind

commit 4d06dd53 upstream.

usbnet_link_change will call schedule_work and should be
avoided if bind is failing. Otherwise we will end up with
scheduled work referring to a netdev which has gone away.

Instead of making the call conditional, we can just defer
it to usbnet_probe, using the driver_info flag made for
this purpose.

Fixes: 8a34b0ae ("usbnet: cdc_ncm: apply usbnet_link_change")
Reported-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarBjørn Mork <bjorn@mork.no>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarAmit Pundir <amit.pundir@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 18377401
...@@ -952,23 +952,12 @@ EXPORT_SYMBOL_GPL(cdc_ncm_select_altsetting); ...@@ -952,23 +952,12 @@ EXPORT_SYMBOL_GPL(cdc_ncm_select_altsetting);
static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf) static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf)
{ {
int ret;
/* MBIM backwards compatible function? */ /* MBIM backwards compatible function? */
if (cdc_ncm_select_altsetting(intf) != CDC_NCM_COMM_ALTSETTING_NCM) if (cdc_ncm_select_altsetting(intf) != CDC_NCM_COMM_ALTSETTING_NCM)
return -ENODEV; return -ENODEV;
/* The NCM data altsetting is fixed */ /* The NCM data altsetting is fixed */
ret = cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM); return cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM);
/*
* We should get an event when network connection is "connected" or
* "disconnected". Set network connection in "disconnected" state
* (carrier is OFF) during attach, so the IP network stack does not
* start IPv6 negotiation and more.
*/
usbnet_link_change(dev, 0, 0);
return ret;
} }
static void cdc_ncm_align_tail(struct sk_buff *skb, size_t modulus, size_t remainder, size_t max) static void cdc_ncm_align_tail(struct sk_buff *skb, size_t modulus, size_t remainder, size_t max)
...@@ -1510,7 +1499,8 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb) ...@@ -1510,7 +1499,8 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
static const struct driver_info cdc_ncm_info = { static const struct driver_info cdc_ncm_info = {
.description = "CDC NCM", .description = "CDC NCM",
.flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET, .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
| FLAG_LINK_INTR,
.bind = cdc_ncm_bind, .bind = cdc_ncm_bind,
.unbind = cdc_ncm_unbind, .unbind = cdc_ncm_unbind,
.manage_power = usbnet_manage_power, .manage_power = usbnet_manage_power,
...@@ -1523,7 +1513,7 @@ static const struct driver_info cdc_ncm_info = { ...@@ -1523,7 +1513,7 @@ static const struct driver_info cdc_ncm_info = {
static const struct driver_info wwan_info = { static const struct driver_info wwan_info = {
.description = "Mobile Broadband Network Device", .description = "Mobile Broadband Network Device",
.flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
| FLAG_WWAN, | FLAG_LINK_INTR | FLAG_WWAN,
.bind = cdc_ncm_bind, .bind = cdc_ncm_bind,
.unbind = cdc_ncm_unbind, .unbind = cdc_ncm_unbind,
.manage_power = usbnet_manage_power, .manage_power = usbnet_manage_power,
...@@ -1536,7 +1526,7 @@ static const struct driver_info wwan_info = { ...@@ -1536,7 +1526,7 @@ static const struct driver_info wwan_info = {
static const struct driver_info wwan_noarp_info = { static const struct driver_info wwan_noarp_info = {
.description = "Mobile Broadband Network Device (NO ARP)", .description = "Mobile Broadband Network Device (NO ARP)",
.flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
| FLAG_WWAN | FLAG_NOARP, | FLAG_LINK_INTR | FLAG_WWAN | FLAG_NOARP,
.bind = cdc_ncm_bind, .bind = cdc_ncm_bind,
.unbind = cdc_ncm_unbind, .unbind = cdc_ncm_unbind,
.manage_power = usbnet_manage_power, .manage_power = usbnet_manage_power,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment