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>
This commit is contained in:
parent
ac817f5ad0
commit
0b2122e493
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user