aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2009-12-10 14:32:49 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-23 14:23:44 -0500
commite6309e7568d4b9d62298a887b10de42df11cb8c1 (patch)
treee4c1fc9b2771eb95b9206668b2f1f7798088e1ab /drivers/base
parent099c2f21d8cf0724b85abb2c589d6276953781b7 (diff)
Driver-core: Fix bogus 0 error return in device_add()
If device_add() is called with a device which does not have dev->p set up, then device_private_init() is called. If that succeeds, then the error variable is set to 0. Now if the dev_name(dev) check further down fails, then device_add() correctly terminates, but returns 0. That of course lets the driver progress. If later another driver uses this half set up device as parent then device_add() of the child device explodes and renders sysfs completely unusable. Set the error to -EINVAL if dev_name() check fails. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: "Hans J. Koch" <hjk@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/core.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 83afc8b8f27b..282025770429 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -909,8 +909,10 @@ int device_add(struct device *dev)
909 dev->init_name = NULL; 909 dev->init_name = NULL;
910 } 910 }
911 911
912 if (!dev_name(dev)) 912 if (!dev_name(dev)) {
913 error = -EINVAL;
913 goto name_error; 914 goto name_error;
915 }
914 916
915 pr_debug("device: '%s': %s\n", dev_name(dev), __func__); 917 pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
916 918