aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorCornelia Huck <cornelia.huck@de.ibm.com>2008-02-27 09:38:23 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-03-04 17:47:05 -0500
commitc1fe539a7e031302af1d121163e7ce68e679ba8c (patch)
treec53ec9b8421487df0a5215f05c90a327bae19942 /drivers/base/core.c
parent135dee0cd0eb2638fab899b428e51f00e8c046a8 (diff)
Driver core: Fix cleanup when failing device_add().
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>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 7f59c2f2ebcb..7de543d1d0b4 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -621,7 +621,8 @@ static struct kobject *get_device_parent(struct device *dev,
621static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir) 621static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
622{ 622{
623 /* see if we live in a "glue" directory */ 623 /* see if we live in a "glue" directory */
624 if (!dev->class || glue_dir->kset != &dev->class->class_dirs) 624 if (!glue_dir || !dev->class ||
625 glue_dir->kset != &dev->class->class_dirs)
625 return; 626 return;
626 627
627 kobject_put(glue_dir); 628 kobject_put(glue_dir);
@@ -773,7 +774,7 @@ int device_add(struct device *dev)
773 dev = get_device(dev); 774 dev = get_device(dev);
774 if (!dev || !strlen(dev->bus_id)) { 775 if (!dev || !strlen(dev->bus_id)) {
775 error = -EINVAL; 776 error = -EINVAL;
776 goto Error; 777 goto Done;
777 } 778 }
778 779
779 pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); 780 pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__);