login
Header Space

 
 

[PATCH 7/8] Driver core: Fix cleanup when failing device_add().

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: Cornelia Huck <cornelia.huck@...>, Greg Kroah-Hartman <gregkh@...>
Date: Tuesday, March 4, 2008 - 7:18 pm

From: Cornelia Huck <cornelia.huck@de.ibm.com>

Driver core: Fix cleanup when failing device_add().

 - Don't call cleanup_device_parent() if we didn't call setup_parent().
 - dev->kobj.parent may be NULL when cleanup_device_parent() is called,
   so we need to handle glue_dir == NULL in cleanup_glue_dir().

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/base/core.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 7f59c2f..7de543d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -621,7 +621,8 @@ static struct kobject *get_device_parent(struct device *dev,
 static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
 {
 	/* see if we live in a "glue" directory */
-	if (!dev->class || glue_dir->kset != &dev->class->class_dirs)
+	if (!glue_dir || !dev->class ||
+	    glue_dir->kset != &dev->class->class_dirs)
 		return;
 
 	kobject_put(glue_dir);
@@ -773,7 +774,7 @@ int device_add(struct device *dev)
 	dev = get_device(dev);
 	if (!dev || !strlen(dev->bus_id)) {
 		error = -EINVAL;
-		goto Error;
+		goto Done;
 	}
 
 	pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__);
-- 
1.5.4.3

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 8/8] debugfs: fix sparse warnings, Greg Kroah-Hartman, (Tue Mar 4, 7:18 pm)
[PATCH 7/8] Driver core: Fix cleanup when failing device_add..., Greg Kroah-Hartman, (Tue Mar 4, 7:18 pm)
[PATCH 6/8] driver core: Remove dpm_sysfs_remove() from erro..., Greg Kroah-Hartman, (Tue Mar 4, 7:18 pm)
[PATCH 5/8] PM: fix new mutex-locking bug in the PM core, Greg Kroah-Hartman, (Tue Mar 4, 7:18 pm)
[PATCH 4/8] PM: Do not acquire device semaphores upfront dur..., Greg Kroah-Hartman, (Tue Mar 4, 7:18 pm)
[PATCH 3/8] kobject: properly initialize ksets, Greg Kroah-Hartman, (Tue Mar 4, 7:18 pm)
[PATCH 2/8] sysfs: CONFIG_SYSFS_DEPRECATED fix, Greg Kroah-Hartman, (Tue Mar 4, 7:18 pm)
[PATCH 1/8] driver core: fix up Kconfig text for CONFIG_SYSF..., Greg Kroah-Hartman, (Tue Mar 4, 7:18 pm)
speck-geostationary