* [6/9] driver core fixes: device_add() cleanup on error
@ 2006-09-22 9:37 Cornelia Huck
0 siblings, 0 replies; only message in thread
From: Cornelia Huck @ 2006-09-22 9:37 UTC (permalink / raw)
To: Greg K-H; +Cc: linux-kernel
From: Cornelia Huck <cornelia.huck@de.ibm.com>
Check for return code of device_create_file() and correct cleanup in
the error case in device_add().
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
drivers/base/core.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
--- linux-2.6-CH.orig/drivers/base/core.c
+++ linux-2.6-CH/drivers/base/core.c
@@ -437,14 +437,16 @@ int device_add(struct device *dev)
if (dev->driver)
dev->uevent_attr.attr.owner = dev->driver->owner;
dev->uevent_attr.store = store_uevent;
- device_create_file(dev, &dev->uevent_attr);
+ error = device_create_file(dev, &dev->uevent_attr);
+ if (error)
+ goto attrError;
if (MAJOR(dev->devt)) {
struct device_attribute *attr;
attr = kzalloc(sizeof(*attr), GFP_KERNEL);
if (!attr) {
error = -ENOMEM;
- goto PMError;
+ goto ueventattrError;
}
attr->attr.name = "dev";
attr->attr.mode = S_IRUGO;
@@ -454,7 +456,7 @@ int device_add(struct device *dev)
error = device_create_file(dev, attr);
if (error) {
kfree(attr);
- goto attrError;
+ goto ueventattrError;
}
dev->devt_attr = attr;
@@ -515,6 +517,8 @@ int device_add(struct device *dev)
device_remove_file(dev, dev->devt_attr);
kfree(dev->devt_attr);
}
+ ueventattrError:
+ device_remove_file(dev, &dev->uevent_attr);
attrError:
kobject_uevent(&dev->kobj, KOBJ_REMOVE);
kobject_del(&dev->kobj);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-09-22 9:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-22 9:37 [6/9] driver core fixes: device_add() cleanup on error Cornelia Huck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).