Commit bbc780f8 authored by David Herrmann's avatar David Herrmann Committed by Greg Kroah-Hartman

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: default avatarDavid Herrmann <dh.herrmann@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d0f80f9a
...@@ -1603,6 +1603,7 @@ device_create_groups_vargs(struct class *class, struct device *parent, ...@@ -1603,6 +1603,7 @@ device_create_groups_vargs(struct class *class, struct device *parent,
goto error; goto error;
} }
device_initialize(dev);
dev->devt = devt; dev->devt = devt;
dev->class = class; dev->class = class;
dev->parent = parent; dev->parent = parent;
...@@ -1614,7 +1615,7 @@ device_create_groups_vargs(struct class *class, struct device *parent, ...@@ -1614,7 +1615,7 @@ device_create_groups_vargs(struct class *class, struct device *parent,
if (retval) if (retval)
goto error; goto error;
retval = device_register(dev); retval = device_add(dev);
if (retval) if (retval)
goto error; goto error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment