summaryrefslogtreecommitdiff
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2006-10-05 17:03:24 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-10-18 12:49:55 -0700
commitf70fa6296c2ec8f541f0a9b406ccc2d9d127d639 (patch)
treef9fd9bbb13a62683c6b41612cfb34fa3894f8676 /drivers/base/core.c
parent952ab431cd36c7ab573f685af8679c3677cbdc29 (diff)
Driver core: Don't ignore error returns from probing
This patch (as797) fixes device_add() in the driver core. It needs to pay attention when the driver for a new device reports an error. At the same time, since bus_remove_device() undoes the effects of both bus_add_device() and bus_attach_device(), it needs to check whether the bus_attach_device step failed. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 41f3dca55cd0..68ad11af22b4 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -479,7 +479,8 @@ int device_add(struct device *dev)
if ((error = bus_add_device(dev)))
goto BusError;
kobject_uevent(&dev->kobj, KOBJ_ADD);
- bus_attach_device(dev);
+ if ((error = bus_attach_device(dev)))
+ goto AttachError;
if (parent)
klist_add_tail(&dev->knode_parent, &parent->klist_children);
@@ -498,6 +499,8 @@ int device_add(struct device *dev)
kfree(class_name);
put_device(dev);
return error;
+ AttachError:
+ bus_remove_device(dev);
BusError:
device_pm_remove(dev);
PMError: