* [PATCH net] sfp: fix sfp-bus oops when removing socket/upstream
@ 2017-12-26 23:15 Russell King
2017-12-27 19:29 ` Florian Fainelli
2018-01-02 18:41 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Russell King @ 2017-12-26 23:15 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli; +Cc: netdev
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 <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/sfp-bus.c | 6 ++++--
1 file 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;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] sfp: fix sfp-bus oops when removing socket/upstream
2017-12-26 23:15 [PATCH net] sfp: fix sfp-bus oops when removing socket/upstream Russell King
@ 2017-12-27 19:29 ` Florian Fainelli
2018-01-02 18:41 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2017-12-27 19:29 UTC (permalink / raw)
To: Russell King, Andrew Lunn; +Cc: netdev
On 12/26/2017 03:15 PM, Russell King wrote:
> 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 <rmk+kernel@armlinux.org.uk>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Fixes: ce0aa27ff3f6 ("sfp: add sfp-bus to bridge between network devices
and sfp cages")
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] sfp: fix sfp-bus oops when removing socket/upstream
2017-12-26 23:15 [PATCH net] sfp: fix sfp-bus oops when removing socket/upstream Russell King
2017-12-27 19:29 ` Florian Fainelli
@ 2018-01-02 18:41 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-01-02 18:41 UTC (permalink / raw)
To: rmk+kernel; +Cc: andrew, f.fainelli, netdev
From: Russell King <rmk+kernel@armlinux.org.uk>
Date: Tue, 26 Dec 2017 23:15:17 +0000
> 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 <rmk+kernel@armlinux.org.uk>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-02 18:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-26 23:15 [PATCH net] sfp: fix sfp-bus oops when removing socket/upstream Russell King
2017-12-27 19:29 ` Florian Fainelli
2018-01-02 18:41 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox