]> err.no Git - linux-2.6/commitdiff
[netdrvr] phy: Fix bugs in error handling
authorJeff Garzik <jeff@garzik.org>
Sun, 1 Oct 2006 11:27:46 +0000 (07:27 -0400)
committerJeff Garzik <jeff@garzik.org>
Sun, 1 Oct 2006 11:27:46 +0000 (07:27 -0400)
The recent __must_check stuff flagged some error handling bugs.

phy/fixed.c:
* handle device_bind_driver() failure

phy/phy_device.c:
* handle device_bind_driver() failure
* release rwsem upon failure

Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/phy/fixed.c
drivers/net/phy/phy_device.c

index 19f7ee63276fb56a6ad4f64e0adf3200bf049a59..94b47c8d0ab402c681bb73057adb71952ede69c1 100644 (file)
@@ -289,9 +289,13 @@ static int fixed_mdio_register_device(int number, int speed, int duplex)
                goto probe_fail;
        }
 
-       device_bind_driver(&phydev->dev);
+       err = device_bind_driver(&phydev->dev);
+
        up_write(&phydev->dev.bus->subsys.rwsem);
 
+       if (err)
+               goto probe_fail;
+
        return 0;
 
 probe_fail:
index ecd3da151e2d2a17eca4dabf378a3cef41a341df..3bbd5e70c209100cdf274408200c5ab1b957f9b9 100644 (file)
@@ -212,11 +212,13 @@ struct phy_device *phy_attach(struct net_device *dev,
 
                err = d->driver->probe(d);
 
-               if (err < 0)
-                       return ERR_PTR(err);
+               if (err >= 0)
+                       err = device_bind_driver(d);
 
-               device_bind_driver(d);
                up_write(&d->bus->subsys.rwsem);
+
+               if (err)
+                       return ERR_PTR(err);
        }
 
        if (phydev->attached_dev) {