public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Driver core: fix error handling in device_bind_driver()
@ 2006-10-12  5:05 Dmitry Torokhov
  2006-10-12 18:52 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Torokhov @ 2006-10-12  5:05 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

Subject: Driver core: fix error handling in device_bind_driver()
From: Dmitry Torokhov <dtor@insightbb.com>

When link creation fails we not only need to signal error
but also remove device from driver's list of bound devices.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/base/dd.c |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

Index: work/drivers/base/dd.c
===================================================================
--- work.orig/drivers/base/dd.c
+++ work/drivers/base/dd.c
@@ -41,7 +41,7 @@
  */
 int device_bind_driver(struct device *dev)
 {
-	int ret;
+	int error;
 
 	if (klist_node_attached(&dev->knode_driver)) {
 		printk(KERN_WARNING "%s: device %s already bound\n",
@@ -52,16 +52,23 @@ int device_bind_driver(struct device *de
 	pr_debug("bound device '%s' to driver '%s'\n",
 		 dev->bus_id, dev->driver->name);
 	klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices);
-	ret = sysfs_create_link(&dev->driver->kobj, &dev->kobj,
-			  kobject_name(&dev->kobj));
-	if (ret == 0) {
-		ret = sysfs_create_link(&dev->kobj, &dev->driver->kobj,
-					"driver");
-		if (ret)
-			sysfs_remove_link(&dev->driver->kobj,
-					kobject_name(&dev->kobj));
-	}
-	return ret;
+	error = sysfs_create_link(&dev->driver->kobj, &dev->kobj,
+				  kobject_name(&dev->kobj));
+	if (error)
+		goto err_remove_list;
+
+	error = sysfs_create_link(&dev->kobj, &dev->driver->kobj,
+				  "driver");
+	if (error)
+		goto err_remove_link;
+
+	return 0;
+
+ err_remove_link:
+	sysfs_remove_link(&dev->driver->kobj, kobject_name(&dev->kobj));
+ err_remove_list:
+	klist_remove(&dev->knode_driver);
+	return error;
 }
 
 struct stupid_thread_structure {

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Driver core: fix error handling in device_bind_driver()
  2006-10-12  5:05 [PATCH] Driver core: fix error handling in device_bind_driver() Dmitry Torokhov
@ 2006-10-12 18:52 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2006-10-12 18:52 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Greg KH, linux-kernel

On Thu, 12 Oct 2006 01:05:55 -0400
Dmitry Torokhov <dtor@insightbb.com> wrote:

> Subject: Driver core: fix error handling in device_bind_driver()
> From: Dmitry Torokhov <dtor@insightbb.com>
> 
> When link creation fails we not only need to signal error
> but also remove device from driver's list of bound devices.
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> ---
> 
>  drivers/base/dd.c |   29 ++++++++++++++++++-----------
>  1 files changed, 18 insertions(+), 11 deletions(-)
> 
> Index: work/drivers/base/dd.c
> ===================================================================
> --- work.orig/drivers/base/dd.c
> +++ work/drivers/base/dd.c

This code has undergone basic restructuring in Greg's development tree.  A
patch against rc1-mm1 would apply.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-10-12 18:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-12  5:05 [PATCH] Driver core: fix error handling in device_bind_driver() Dmitry Torokhov
2006-10-12 18:52 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox