linux-stable/drivers/net/usb
Lukas Wunner fbda837107 usbnet: Run unregister_netdev() before unbind() again
[ Upstream commit d1408f6b4d ]

Commit 2c9d6c2b87 ("usbnet: run unbind() before unregister_netdev()")
sought to fix a use-after-free on disconnect of USB Ethernet adapters.

It turns out that a different fix is necessary to address the issue:
https://lore.kernel.org/netdev/18b3541e5372bc9b9fc733d422f4e698c089077c.1650177997.git.lukas@wunner.de/

So the commit was not necessary.

The commit made binding and unbinding of USB Ethernet asymmetrical:
Before, usbnet_probe() first invoked the ->bind() callback and then
register_netdev().  usbnet_disconnect() mirrored that by first invoking
unregister_netdev() and then ->unbind().

Since the commit, the order in usbnet_disconnect() is reversed and no
longer mirrors usbnet_probe().

One consequence is that a PHY disconnected (and stopped) in ->unbind()
is afterwards stopped once more by unregister_netdev() as it closes the
netdev before unregistering.  That necessitates a contortion in ->stop()
because the PHY may only be stopped if it hasn't already been
disconnected.

Reverting the commit allows making the call to phy_stop() unconditional
in ->stop().

Tested-by: Oleksij Rempel <o.rempel@pengutronix.de> # LAN9514/9512/9500
Tested-by: Ferry Toth <fntoth@gmail.com> # LAN9514
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Acked-by: Oliver Neukum <oneukum@suse.com>
Cc: Martyn Welch <martyn.welch@collabora.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-09 10:25:27 +02:00
..
aqc111.c net: usb: aqc111: Fix out-of-bounds accesses in RX fixup 2022-04-20 09:36:22 +02:00
aqc111.h
asix.h net: asix: add proper error handling of usb read errors 2022-04-08 13:58:03 +02:00
asix_common.c net: asix: add proper error handling of usb read errors 2022-04-08 13:58:03 +02:00
asix_devices.c usbnet: Run unregister_netdev() before unbind() again 2022-06-09 10:25:27 +02:00
ax88172a.c
ax88179_178a.c net: usb: ax88179_178a: Fix out-of-bounds accesses in RX fixup 2022-02-11 10:57:07 +01:00
catc.c usbb: catc: use correct API for MAC addresses 2021-10-25 15:34:02 +01:00
cdc-phonet.c
cdc_eem.c
cdc_ether.c USB: zaurus: support another broken Zaurus 2022-02-14 14:37:15 +00:00
cdc_mbim.c net: usb: cdc_mbim: avoid altsetting toggling for Telit FN990 2022-02-17 14:50:43 +00:00
cdc_ncm.c CDC-NCM: avoid overflow in sanity checking 2022-02-15 14:56:10 +00:00
cdc_subset.c
ch9200.c net: usb: don't write directly to netdev->dev_addr 2021-10-22 10:16:01 -07:00
cx82310_eth.c net: usb: don't write directly to netdev->dev_addr 2021-10-22 10:16:01 -07:00
dm9601.c ethernet: constify references to netdev->dev_addr in drivers 2021-10-14 09:22:11 -07:00
gl620a.c
hso.c
huawei_cdc_ncm.c
int51x1.c
ipheth.c ipheth: fix EOVERFLOW in ipheth_rcvbulk_callback 2022-02-01 20:25:38 -08:00
kalmia.c
kaweth.c net: usb: don't write directly to netdev->dev_addr 2021-10-22 10:16:01 -07:00
Kconfig lan78xx: select CRC32 2021-10-15 14:34:35 +01:00
lan78xx.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-12-16 16:13:19 -08:00
lan78xx.h
lg-vl600.c
Makefile
mcs7830.c net: mcs7830: handle usb read errors properly 2022-01-09 16:35:50 -08:00
net1080.c
pegasus.c net: usb: pegasus: Do not drop long Ethernet frames 2021-12-27 14:52:06 +00:00
pegasus.h
plusb.c
qmi_wwan.c net: usb: qmi_wwan: Add support for Dell DW5829e 2022-02-09 17:13:52 -08:00
r8152.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-01-05 14:36:10 -08:00
r8153_ecm.c
rndis_host.c rndis_host: support Hytera digital radios 2022-01-02 16:12:45 +00:00
rtl8150.c
sierra_net.c net: usb: don't write directly to netdev->dev_addr 2021-10-22 10:16:01 -07:00
smsc75xx.c usb: smsc: use eth_hw_addr_set() 2021-10-22 10:15:56 -07:00
smsc75xx.h
smsc95xx.c usbnet: Run unregister_netdev() before unbind() again 2022-06-09 10:25:27 +02:00
smsc95xx.h
sr9700.c sr9700: sanity check for packet length 2022-02-18 11:05:08 +00:00
sr9700.h
sr9800.c net: usb: don't write directly to netdev->dev_addr 2021-10-22 10:16:01 -07:00
sr9800.h
usbnet.c usbnet: Run unregister_netdev() before unbind() again 2022-06-09 10:25:27 +02:00
zaurus.c USB: zaurus: support another broken Zaurus 2022-02-14 14:37:15 +00:00