Skip to contentSkip to conversation

driver core: handle bus_attach_device() failure

PATCH In review Akinobu Mita 2 participants 2 messages Oct 9, 2006 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver core: handle bus_attach_device() failure

This patch handles bus_attach_device() failure in device_add().

Cc Greg Kroah-Hartman <[email protected]>
 drivers/base/core.c |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/base/core.c +5 -1
Index: 2.6-mm/drivers/base/core.c
===================================================================
@@ -530,7 +530,9 @@ 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 BusAttachError;
+
 	if (parent)
 		klist_add_tail(&dev->knode_parent, &parent->klist_children);
 
@@ -548,6 +550,8 @@ int device_add(struct device *dev)
  Done:
 	put_device(dev);
 	return error;
+ BusAttachError:
+	bus_remove_device(dev);
  BusError:
 	device_pm_remove(dev);
  PMError:
#1 lore raw
Quoted 24 lines · On Mon, 9 Oct 2006 18:12:01 +0900, [email protected] (Akinobu Mita) wrote:

This patch handles bus_attach_device() failure in device_add().

Cc Greg Kroah-Hartman <[email protected]>
 drivers/base/core.c |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

Index: 2.6-mm/drivers/base/core.c
===================================================================

drivers/base/core.c +3 -1
@@ -530,7 +530,9 @@ 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 BusAttachError;
+
 	if (parent)
 		klist_add_tail(&dev->knode_parent, &parent->klist_children);
 

drivers/base/core.c int device_add(struct device *dev) · line 557

Quoted 8 lines
drivers/base/core.c +2 -0
@@ -548,6 +550,8 @@ int device_add(struct device *dev)
  Done:
 	put_device(dev);
 	return error;
+ BusAttachError:
+	bus_remove_device(dev);
  BusError:
 	device_pm_remove(dev);
  PMError:

This won't quite work :)

See also
http://marc.theaimsgroup.com/?l=linux-kernel&m=116008235424179&w=2 ff. for a discussion on it. I'll send an updated patch soon :)

Signature · 3 lines
Cornelia Huck
Linux for zSeries Developer
Tel.: +49-7031-16-4837, Mail: [email protected]