diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2017-12-26 23:15:17 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-01-02 13:40:28 -0500 |
commit | 0b2122e4934c7783d336397864e34ee53aad0965 (patch) | |
tree | 1a802912a05f18c1ad045f68210623f13dee5e4b /drivers/net/phy/sfp-bus.c | |
parent | ac817f5ad066697e4d4d35ec68c974eba2c5f17a (diff) | |
download | linux-stable-0b2122e4934c7783d336397864e34ee53aad0965.tar.gz linux-stable-0b2122e4934c7783d336397864e34ee53aad0965.tar.bz2 linux-stable-0b2122e4934c7783d336397864e34ee53aad0965.zip |
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.
Fixes: ce0aa27ff3f6 ("sfp: add sfp-bus to bridge between network devices and sfp cages")
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/sfp-bus.c')
-rw-r--r-- | drivers/net/phy/sfp-bus.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c index 8a1b1f4c1b7c..ab64a142b832 100644 --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c @@ -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; |