Skip to contentSkip to conversation

net: dsa: loop: Do not unregister invalid fixed PHY

PATCH In review Florian Fainelli 3 participants 3 messages Sep 2, 2017 – Sep 4, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: dsa: loop: Do not unregister invalid fixed PHY

During error injection it was possible to crash in dsa_loop_exit() because of an attempt to unregister an invalid PHY. We actually want to the driver probing in dsa_loop_init() even though fixed_phy_register() may return an error to exercise how DSA deals with such cases, but we should not be crashing during driver removal.

Fixes 98cd1552ea27 ("net: dsa: Mock-up driver")
---
 drivers/net/dsa/dsa_loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/dsa_loop.c +1 -1
index fdd8f3872102..8150e3a3c8dd 100644
@@ -390,7 +390,7 @@ static void __exit dsa_loop_exit(void)
 
 	mdio_driver_unregister(&dsa_loop_drv);
 	for (i = 0; i < NUM_FIXED_PHYS; i++)
-		if (phydevs[i])
+		if (!IS_ERR(phydevs[i]))
 			fixed_phy_unregister(phydevs[i]);
 }
 module_exit(dsa_loop_exit);
Signature · 1 line
2.11.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Florian Fainelli

During error injection it was possible to crash in dsa_loop_exit() because of an attempt to unregister an invalid PHY. We actually want to the driver probing in dsa_loop_init() even though fixed_phy_register() may return an error to exercise how DSA deals with such cases, but we should not be crashing during driver removal.

Fixes 98cd1552ea27 ("net: dsa: Mock-up driver")

Andrew

maintainer
#2 lore raw
In reply to Florian Fainelli

From: Florian Fainelli <[email protected]>
Date: Sat, 2 Sep 2017 08:56:45 -0700

Quoted 8 lines

During error injection it was possible to crash in dsa_loop_exit() because of an attempt to unregister an invalid PHY. We actually want to the driver probing in dsa_loop_init() even though fixed_phy_register() may return an error to exercise how DSA deals with such cases, but we should not be crashing during driver removal.

Fixes 98cd1552ea27 ("net: dsa: Mock-up driver")

Applied and queued up for -stable, thanks.