public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpuidle: qcom_spm: Fix missing put_device() call in spm_cpuidle_register
@ 2021-12-30 11:42 Miaoqian Lin
  0 siblings, 0 replies; only message in thread
From: Miaoqian Lin @ 2021-12-30 11:42 UTC (permalink / raw)
  Cc: linmq006, Andy Gross, Bjorn Andersson, Rafael J. Wysocki,
	Daniel Lezcano, Stephan Gerhold, AngeloGioacchino Del Regno,
	linux-arm-msm, linux-pm, linux-kernel

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")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/cpuidle/cpuidle-qcom-spm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-qcom-spm.c b/drivers/cpuidle/cpuidle-qcom-spm.c
index 01e77913a414..6638c1de90c3 100644
--- a/drivers/cpuidle/cpuidle-qcom-spm.c
+++ b/drivers/cpuidle/cpuidle-qcom-spm.c
@@ -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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-30 11:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-30 11:42 [PATCH] cpuidle: qcom_spm: Fix missing put_device() call in spm_cpuidle_register Miaoqian Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox