Skip to contentSkip to conversation

cpuidle: qcom_spm: Fix missing put_device() call in spm_cpuidle_register

PATCH RESEND New Miaoqian Lin 1 participant 1 message Jun 2, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 cpuidle: qcom_spm: Fix missing put_device() call in spm_cpuidle_register

The reference taken by 'of_find_device_by_node()' must be released when not needed anymore.
Add the corresponding 'put_device()' in the error handling paths.

Fixes 60f3692 ("cpuidle: qcom_spm: Detach state machine from main SPM handling")

---

---
 drivers/cpuidle/cpuidle-qcom-spm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/cpuidle/cpuidle-qcom-spm.c +6 -2
index beedf22cbe78..c734f914b616 100644
@@ -107,12 +107,16 @@ static int spm_cpuidle_register(struct device *cpuidle_dev, int cpu)
 		return -ENODEV;
 
 	data = devm_kzalloc(cpuidle_dev, sizeof(*data), GFP_KERNEL);
-	if (!data)
+	if (!data) {
+		put_device(&pdev->dev);
 		return -ENOMEM;
+	}
 
 	data->spm = dev_get_drvdata(&pdev->dev);
-	if (!data->spm)
+	if (!data->spm) {
+		put_device(&pdev->dev);
 		return -EINVAL;
+	}
 
 	data->cpuidle_driver = qcom_spm_idle_driver;
 	data->cpuidle_driver.cpumask = (struct cpumask *)cpumask_of(cpu);
Signature · 1 line
2.25.1