diff options
author | Cornelia Huck <cornelia.huck@de.ibm.com> | 2006-09-22 05:37:13 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-10-18 15:49:55 -0400 |
commit | a306eea40952e6365301e8a2f7d5ffa9c6a1921b (patch) | |
tree | 5a5b74ef17286728d9b3d5a1eee4e21c73b6e9e6 /drivers | |
parent | 513e7337adc32cdfbffecb99953e45a44e812c2d (diff) |
driver core fixes: device_add() cleanup on error
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/core.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index aee3743bd4a3..365f709715ef 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -433,14 +433,16 @@ int device_add(struct device *dev) | |||
433 | if (dev->driver) | 433 | if (dev->driver) |
434 | dev->uevent_attr.attr.owner = dev->driver->owner; | 434 | dev->uevent_attr.attr.owner = dev->driver->owner; |
435 | dev->uevent_attr.store = store_uevent; | 435 | dev->uevent_attr.store = store_uevent; |
436 | device_create_file(dev, &dev->uevent_attr); | 436 | error = device_create_file(dev, &dev->uevent_attr); |
437 | if (error) | ||
438 | goto attrError; | ||
437 | 439 | ||
438 | if (MAJOR(dev->devt)) { | 440 | if (MAJOR(dev->devt)) { |
439 | struct device_attribute *attr; | 441 | struct device_attribute *attr; |
440 | attr = kzalloc(sizeof(*attr), GFP_KERNEL); | 442 | attr = kzalloc(sizeof(*attr), GFP_KERNEL); |
441 | if (!attr) { | 443 | if (!attr) { |
442 | error = -ENOMEM; | 444 | error = -ENOMEM; |
443 | goto PMError; | 445 | goto ueventattrError; |
444 | } | 446 | } |
445 | attr->attr.name = "dev"; | 447 | attr->attr.name = "dev"; |
446 | attr->attr.mode = S_IRUGO; | 448 | attr->attr.mode = S_IRUGO; |
@@ -450,7 +452,7 @@ int device_add(struct device *dev) | |||
450 | error = device_create_file(dev, attr); | 452 | error = device_create_file(dev, attr); |
451 | if (error) { | 453 | if (error) { |
452 | kfree(attr); | 454 | kfree(attr); |
453 | goto attrError; | 455 | goto ueventattrError; |
454 | } | 456 | } |
455 | 457 | ||
456 | dev->devt_attr = attr; | 458 | dev->devt_attr = attr; |
@@ -507,6 +509,8 @@ int device_add(struct device *dev) | |||
507 | device_remove_file(dev, dev->devt_attr); | 509 | device_remove_file(dev, dev->devt_attr); |
508 | kfree(dev->devt_attr); | 510 | kfree(dev->devt_attr); |
509 | } | 511 | } |
512 | ueventattrError: | ||
513 | device_remove_file(dev, &dev->uevent_attr); | ||
510 | attrError: | 514 | attrError: |
511 | kobject_uevent(&dev->kobj, KOBJ_REMOVE); | 515 | kobject_uevent(&dev->kobj, KOBJ_REMOVE); |
512 | kobject_del(&dev->kobj); | 516 | kobject_del(&dev->kobj); |