Skip to content

Commit

Permalink
PM: Avoid calling kfree() under spinlock in dev_pm_put_subsys_data()
Browse files Browse the repository at this point in the history
Fix dev_pm_put_subsys_data() so that it doesn't call kfree() under
a spinlock and make it return 1 whenever it leaves NULL
power.subsys_data (regardless of the reason).

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Reviewed-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Shuah Khan authored and Rafael J. Wysocki committed May 12, 2013
1 parent f722406 commit d5e1670
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/base/power/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,24 @@ EXPORT_SYMBOL_GPL(dev_pm_get_subsys_data);
int dev_pm_put_subsys_data(struct device *dev)
{
struct pm_subsys_data *psd;
int ret = 0;
int ret = 1;

spin_lock_irq(&dev->power.lock);

psd = dev_to_psd(dev);
if (!psd) {
ret = -EINVAL;
if (!psd)
goto out;
}

if (--psd->refcount == 0) {
dev->power.subsys_data = NULL;
kfree(psd);
ret = 1;
} else {
psd = NULL;
ret = 0;
}

out:
spin_unlock_irq(&dev->power.lock);
kfree(psd);

return ret;
}
Expand Down

0 comments on commit d5e1670

Please sign in to comment.