aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/core.c10
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);