aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/bus.c4
-rw-r--r--drivers/base/core.c5
-rw-r--r--drivers/base/driver.c4
-rw-r--r--drivers/base/power/main.c4
4 files changed, 15 insertions, 2 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index dc030f1f00f1..c6599618523e 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -700,8 +700,10 @@ int bus_add_driver(struct device_driver *drv)
700 } 700 }
701 701
702 kobject_uevent(&priv->kobj, KOBJ_ADD); 702 kobject_uevent(&priv->kobj, KOBJ_ADD);
703 return error; 703 return 0;
704out_unregister: 704out_unregister:
705 kfree(drv->p);
706 drv->p = NULL;
705 kobject_put(&priv->kobj); 707 kobject_put(&priv->kobj);
706out_put_bus: 708out_put_bus:
707 bus_put(bus); 709 bus_put(bus);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 4aa527b8a913..1977d4beb89e 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -879,7 +879,7 @@ int device_add(struct device *dev)
879 } 879 }
880 880
881 if (!dev_name(dev)) 881 if (!dev_name(dev))
882 goto done; 882 goto name_error;
883 883
884 pr_debug("device: '%s': %s\n", dev_name(dev), __func__); 884 pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
885 885
@@ -978,6 +978,9 @@ done:
978 cleanup_device_parent(dev); 978 cleanup_device_parent(dev);
979 if (parent) 979 if (parent)
980 put_device(parent); 980 put_device(parent);
981name_error:
982 kfree(dev->p);
983 dev->p = NULL;
981 goto done; 984 goto done;
982} 985}
983 986
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index c51f11bb29ae..8ae0f63602e0 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -257,6 +257,10 @@ EXPORT_SYMBOL_GPL(driver_register);
257 */ 257 */
258void driver_unregister(struct device_driver *drv) 258void driver_unregister(struct device_driver *drv)
259{ 259{
260 if (!drv || !drv->p) {
261 WARN(1, "Unexpected driver unregister!\n");
262 return;
263 }
260 driver_remove_groups(drv, drv->groups); 264 driver_remove_groups(drv, drv->groups);
261 bus_remove_driver(drv); 265 bus_remove_driver(drv);
262} 266}
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 69b4ddb7de3b..3e4bc699bc0f 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -357,6 +357,7 @@ static void dpm_power_up(pm_message_t state)
357{ 357{
358 struct device *dev; 358 struct device *dev;
359 359
360 mutex_lock(&dpm_list_mtx);
360 list_for_each_entry(dev, &dpm_list, power.entry) 361 list_for_each_entry(dev, &dpm_list, power.entry)
361 if (dev->power.status > DPM_OFF) { 362 if (dev->power.status > DPM_OFF) {
362 int error; 363 int error;
@@ -366,6 +367,7 @@ static void dpm_power_up(pm_message_t state)
366 if (error) 367 if (error)
367 pm_dev_err(dev, state, " early", error); 368 pm_dev_err(dev, state, " early", error);
368 } 369 }
370 mutex_unlock(&dpm_list_mtx);
369} 371}
370 372
371/** 373/**
@@ -614,6 +616,7 @@ int device_power_down(pm_message_t state)
614 int error = 0; 616 int error = 0;
615 617
616 suspend_device_irqs(); 618 suspend_device_irqs();
619 mutex_lock(&dpm_list_mtx);
617 list_for_each_entry_reverse(dev, &dpm_list, power.entry) { 620 list_for_each_entry_reverse(dev, &dpm_list, power.entry) {
618 error = suspend_device_noirq(dev, state); 621 error = suspend_device_noirq(dev, state);
619 if (error) { 622 if (error) {
@@ -622,6 +625,7 @@ int device_power_down(pm_message_t state)
622 } 625 }
623 dev->power.status = DPM_OFF_IRQ; 626 dev->power.status = DPM_OFF_IRQ;
624 } 627 }
628 mutex_unlock(&dpm_list_mtx);
625 if (error) 629 if (error)
626 device_power_up(resume_event(state)); 630 device_power_up(resume_event(state));
627 return error; 631 return error;