net: dsa: loop: Do not unregister invalid fixed PHY
authorFlorian Fainelli <f.fainelli@gmail.com>
Sat, 2 Sep 2017 15:56:45 +0000 (08:56 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 4 Sep 2017 03:18:25 +0000 (20:18 -0700)
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")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/dsa_loop.c

index fdd8f38721021253f367b44ac3577429b017bf49..8150e3a3c8dd41aaf79718488747c9b575e5dfb5 100644 (file)
@@ -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);