aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-10-01 07:27:46 -0400
committerJeff Garzik <jeff@garzik.org>2006-10-01 07:27:46 -0400
commitb7a00ecd557859c4037b6465fdd6c9a49b1fa649 (patch)
treec3981f739ee2286ecb36054db52b24e690509060
parent1c7da74c4aab595a994beb5fe728ebf0d0b41f59 (diff)
[netdrvr] phy: Fix bugs in error handling
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>
-rw-r--r--drivers/net/phy/fixed.c6
-rw-r--r--drivers/net/phy/phy_device.c8
2 files changed, 10 insertions, 4 deletions
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index 19f7ee63276f..94b47c8d0ab4 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -289,9 +289,13 @@ static int fixed_mdio_register_device(int number, int speed, int duplex)
289 goto probe_fail; 289 goto probe_fail;
290 } 290 }
291 291
292 device_bind_driver(&phydev->dev); 292 err = device_bind_driver(&phydev->dev);
293
293 up_write(&phydev->dev.bus->subsys.rwsem); 294 up_write(&phydev->dev.bus->subsys.rwsem);
294 295
296 if (err)
297 goto probe_fail;
298
295 return 0; 299 return 0;
296 300
297probe_fail: 301probe_fail:
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index ecd3da151e2d..3bbd5e70c209 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -212,11 +212,13 @@ struct phy_device *phy_attach(struct net_device *dev,
212 212
213 err = d->driver->probe(d); 213 err = d->driver->probe(d);
214 214
215 if (err < 0) 215 if (err >= 0)
216 return ERR_PTR(err); 216 err = device_bind_driver(d);
217 217
218 device_bind_driver(d);
219 up_write(&d->bus->subsys.rwsem); 218 up_write(&d->bus->subsys.rwsem);
219
220 if (err)
221 return ERR_PTR(err);
220 } 222 }
221 223
222 if (phydev->attached_dev) { 224 if (phydev->attached_dev) {