Message ID | 20241112-fix_dev_pm_get_subsys_data-v2-1-3774257ede73@quicinc.com (mailing list archive) |
---|---|
State | Handled Elsewhere, archived |
Headers | show |
Series | [v2] PM: domains: Fix return value of API dev_pm_get_subsys_data() | expand |
diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index cca2fd0a1aed..a3cec013092c 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c @@ -26,6 +26,14 @@ int dev_pm_get_subsys_data(struct device *dev) { struct pm_subsys_data *psd; + spin_lock_irq(&dev->power.lock); + if (dev->power.subsys_data) { + dev->power.subsys_data->refcount++; + spin_unlock_irq(&dev->power.lock); + return 0; + } + spin_unlock_irq(&dev->power.lock); + psd = kzalloc(sizeof(*psd), GFP_KERNEL); if (!psd) return -ENOMEM;