sfp: fix sfp-bus oops when removing socket/upstream
Subsystems (4)
PATCH 1/1 sfp: fix sfp-bus oops when removing socket/upstream
When we remove a socket or upstream, and the other side isn't registered, we dereference a NULL pointer, causing a kernel oops. Fix this.
Signed-off-by Russell King <[email protected]>
--- drivers/net/phy/sfp-bus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/phy/sfp-bus.c +4 -2
@@ -356,7 +356,8 @@ EXPORT_SYMBOL_GPL(sfp_register_upstream);void sfp_unregister_upstream (struct sfp_bus *bus) {rtnl_lock (); -sfp_unregister_bus (bus); +if (bus->sfp) +sfp_unregister_bus (bus); bus->upstream =NULL ; bus->netdev =NULL ;rtnl_unlock ();
@@ -459,7 +460,8 @@ EXPORT_SYMBOL_GPL(sfp_register_socket);void sfp_unregister_socket (struct sfp_bus *bus) {rtnl_lock (); -sfp_unregister_bus (bus); +if (bus->netdev) +sfp_unregister_bus (bus); bus->sfp_dev =NULL ; bus->sfp =NULL ; bus->socket_ops =NULL ;
Signature · 1 line
2.7.4
Quoted 5 lines · Russell King
When we remove a socket or upstream, and the other side isn't registered, we dereference a NULL pointer, causing a kernel oops. Fix this.
Signed-off-by Russell King <[email protected]>
Reviewed-by Florian Fainelli <[email protected]>
Fixes ce0aa27ff3f6 ("sfp: add sfp-bus to bridge between network devices
and sfp cages")
Signature · 1 line
Florian
David Miller
maintainerFrom: Russell King <[email protected]>
Date: Tue, 26 Dec 2017 23:15:17 +0000
Quoted 5 lines
When we remove a socket or upstream, and the other side isn't registered, we dereference a NULL pointer, causing a kernel oops. Fix this.
Signed-off-by Russell King <[email protected]>
Applied and queued up for -stable.