OSDN Git Service

lan78xx: Fix race condition in disconnect handling
authorJohn Efstathiades <john.efstathiades@pebblebay.com>
Tue, 24 Aug 2021 18:56:12 +0000 (19:56 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 25 Aug 2021 09:55:43 +0000 (10:55 +0100)
commit77dfff5bb7e20ce1eaaf4c599d9c54a8f4331124
treecbd56877d6876f2ed3f089c0868b2a5599ab7651
parent5f4cc6e25148cc141f97afb41b4dfe9eb1cce613
lan78xx: Fix race condition in disconnect handling

If there is a device disconnect at roughly the same time as a
deferred PHY link reset there is a race condition that can result
in a kernel lock up due to a null pointer dereference in the
driver's deferred work handling routine lan78xx_delayedwork().
The following changes fix this problem.

Add new status flag EVENT_DEV_DISCONNECT to indicate when the
device has been removed and use it to prevent operations, such as
register access, that will fail once the device is removed.

Stop processing of deferred work items when the driver's USB
disconnect handler is invoked.

Disconnect the PHY only after the network device has been
unregistered and all delayed work has been cancelled.

Signed-off-by: John Efstathiades <john.efstathiades@pebblebay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/lan78xx.c