Skip to content

Commit 4d06dd5

Browse files
bmorkdavem330
authored andcommitted
cdc_ncm: do not call usbnet_link_change from cdc_ncm_bind
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: 8a34b0a ("usbnet: cdc_ncm: apply usbnet_link_change") Reported-by: Andrey Konovalov <andreyknvl@gmail.com> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a9d99ce commit 4d06dd5

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

Diff for: drivers/net/usb/cdc_ncm.c

+5-15
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,6 @@ EXPORT_SYMBOL_GPL(cdc_ncm_select_altsetting);
988988

989989
static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf)
990990
{
991-
int ret;
992-
993991
/* MBIM backwards compatible function? */
994992
if (cdc_ncm_select_altsetting(intf) != CDC_NCM_COMM_ALTSETTING_NCM)
995993
return -ENODEV;
@@ -998,16 +996,7 @@ static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf)
998996
* Additionally, generic NCM devices are assumed to accept arbitrarily
999997
* placed NDP.
1000998
*/
1001-
ret = cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM, 0);
1002-
1003-
/*
1004-
* We should get an event when network connection is "connected" or
1005-
* "disconnected". Set network connection in "disconnected" state
1006-
* (carrier is OFF) during attach, so the IP network stack does not
1007-
* start IPv6 negotiation and more.
1008-
*/
1009-
usbnet_link_change(dev, 0, 0);
1010-
return ret;
999+
return cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM, 0);
10111000
}
10121001

10131002
static void cdc_ncm_align_tail(struct sk_buff *skb, size_t modulus, size_t remainder, size_t max)
@@ -1590,7 +1579,8 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
15901579

15911580
static const struct driver_info cdc_ncm_info = {
15921581
.description = "CDC NCM",
1593-
.flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET,
1582+
.flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
1583+
| FLAG_LINK_INTR,
15941584
.bind = cdc_ncm_bind,
15951585
.unbind = cdc_ncm_unbind,
15961586
.manage_power = usbnet_manage_power,
@@ -1603,7 +1593,7 @@ static const struct driver_info cdc_ncm_info = {
16031593
static const struct driver_info wwan_info = {
16041594
.description = "Mobile Broadband Network Device",
16051595
.flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
1606-
| FLAG_WWAN,
1596+
| FLAG_LINK_INTR | FLAG_WWAN,
16071597
.bind = cdc_ncm_bind,
16081598
.unbind = cdc_ncm_unbind,
16091599
.manage_power = usbnet_manage_power,
@@ -1616,7 +1606,7 @@ static const struct driver_info wwan_info = {
16161606
static const struct driver_info wwan_noarp_info = {
16171607
.description = "Mobile Broadband Network Device (NO ARP)",
16181608
.flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
1619-
| FLAG_WWAN | FLAG_NOARP,
1609+
| FLAG_LINK_INTR | FLAG_WWAN | FLAG_NOARP,
16201610
.bind = cdc_ncm_bind,
16211611
.unbind = cdc_ncm_unbind,
16221612
.manage_power = usbnet_manage_power,

0 commit comments

Comments
 (0)