From bbc780f8bab52fef1784151d3c4982cb1143edd2 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 21 Nov 2013 20:15:48 +0100 Subject: driver core: fix device_create() error path We call put_device() in the error path, which is fine for dev==NULL. However, in case kobject_set_name_vargs() fails, we have dev!=NULL but device_initialized() wasn't called, yet. Fix this by splitting device_register() into explicit calls to device_add() and an early call to device_initialize(). Signed-off-by: David Herrmann Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/base/core.c') diff --git a/drivers/base/core.c b/drivers/base/core.c index 67b180d855b2..aab43fbb8336 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1603,6 +1603,7 @@ device_create_groups_vargs(struct class *class, struct device *parent, goto error; } + device_initialize(dev); dev->devt = devt; dev->class = class; dev->parent = parent; @@ -1614,7 +1615,7 @@ device_create_groups_vargs(struct class *class, struct device *parent, if (retval) goto error; - retval = device_register(dev); + retval = device_add(dev); if (retval) goto error; -- cgit v1.2.3