diff options
| -rw-r--r-- | drivers/base/core.c | 8 | ||||
| -rw-r--r-- | drivers/base/driver.c | 9 |
2 files changed, 5 insertions, 12 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index a0cfda553c9d..9c0070b5bd3e 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
| @@ -423,10 +423,8 @@ struct kset *devices_kset; | |||
| 423 | int device_create_file(struct device *dev, struct device_attribute *attr) | 423 | int device_create_file(struct device *dev, struct device_attribute *attr) |
| 424 | { | 424 | { |
| 425 | int error = 0; | 425 | int error = 0; |
| 426 | if (get_device(dev)) { | 426 | if (dev) |
| 427 | error = sysfs_create_file(&dev->kobj, &attr->attr); | 427 | error = sysfs_create_file(&dev->kobj, &attr->attr); |
| 428 | put_device(dev); | ||
| 429 | } | ||
| 430 | return error; | 428 | return error; |
| 431 | } | 429 | } |
| 432 | 430 | ||
| @@ -437,10 +435,8 @@ int device_create_file(struct device *dev, struct device_attribute *attr) | |||
| 437 | */ | 435 | */ |
| 438 | void device_remove_file(struct device *dev, struct device_attribute *attr) | 436 | void device_remove_file(struct device *dev, struct device_attribute *attr) |
| 439 | { | 437 | { |
| 440 | if (get_device(dev)) { | 438 | if (dev) |
| 441 | sysfs_remove_file(&dev->kobj, &attr->attr); | 439 | sysfs_remove_file(&dev->kobj, &attr->attr); |
| 442 | put_device(dev); | ||
| 443 | } | ||
| 444 | } | 440 | } |
| 445 | 441 | ||
| 446 | /** | 442 | /** |
diff --git a/drivers/base/driver.c b/drivers/base/driver.c index a35f04121a00..ba75184c653c 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c | |||
| @@ -97,10 +97,9 @@ int driver_create_file(struct device_driver *drv, | |||
| 97 | struct driver_attribute *attr) | 97 | struct driver_attribute *attr) |
| 98 | { | 98 | { |
| 99 | int error; | 99 | int error; |
| 100 | if (get_driver(drv)) { | 100 | if (drv) |
| 101 | error = sysfs_create_file(&drv->p->kobj, &attr->attr); | 101 | error = sysfs_create_file(&drv->p->kobj, &attr->attr); |
| 102 | put_driver(drv); | 102 | else |
| 103 | } else | ||
| 104 | error = -EINVAL; | 103 | error = -EINVAL; |
| 105 | return error; | 104 | return error; |
| 106 | } | 105 | } |
| @@ -114,10 +113,8 @@ EXPORT_SYMBOL_GPL(driver_create_file); | |||
| 114 | void driver_remove_file(struct device_driver *drv, | 113 | void driver_remove_file(struct device_driver *drv, |
| 115 | struct driver_attribute *attr) | 114 | struct driver_attribute *attr) |
| 116 | { | 115 | { |
| 117 | if (get_driver(drv)) { | 116 | if (drv) |
| 118 | sysfs_remove_file(&drv->p->kobj, &attr->attr); | 117 | sysfs_remove_file(&drv->p->kobj, &attr->attr); |
| 119 | put_driver(drv); | ||
| 120 | } | ||
| 121 | } | 118 | } |
| 122 | EXPORT_SYMBOL_GPL(driver_remove_file); | 119 | EXPORT_SYMBOL_GPL(driver_remove_file); |
| 123 | 120 | ||
