* [PATCH 0/2] cpuidle: qcom-spm: fix device and OF node leaks at probe
@ 2025-09-08 15:22 Johan Hovold
2025-09-08 15:22 ` [PATCH 1/2] " Johan Hovold
2025-09-08 15:22 ` [PATCH 2/2] cpuidle: qcom-spm: drop unnecessary initialisations Johan Hovold
0 siblings, 2 replies; 6+ messages in thread
From: Johan Hovold @ 2025-09-08 15:22 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano
Cc: AngeloGioacchino Del Regno, linux-arm-msm, linux-pm, linux-kernel,
Johan Hovold
This series fixes a mostly benign device reference leak during probe
(e.g. to avoid it being reproduced in other drivers where it may matter
more).
Included is also a related cleanup.
Johan
Johan Hovold (2):
cpuidle: qcom-spm: fix device and OF node leaks at probe
cpuidle: qcom-spm: drop unnecessary initialisations
drivers/cpuidle/cpuidle-qcom-spm.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
--
2.49.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] cpuidle: qcom-spm: fix device and OF node leaks at probe
2025-09-08 15:22 [PATCH 0/2] cpuidle: qcom-spm: fix device and OF node leaks at probe Johan Hovold
@ 2025-09-08 15:22 ` Johan Hovold
2025-09-08 15:40 ` Konrad Dybcio
2025-09-08 15:22 ` [PATCH 2/2] cpuidle: qcom-spm: drop unnecessary initialisations Johan Hovold
1 sibling, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2025-09-08 15:22 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano
Cc: AngeloGioacchino Del Regno, linux-arm-msm, linux-pm, linux-kernel,
Johan Hovold
Make sure to drop the reference to the saw device taken by
of_find_device_by_node() after retrieving its driver data during
probe().
Also drop the reference to the CPU node sooner to avoid leaking it in
case there is no saw node or device.
Fixes: 60f3692b5f0b ("cpuidle: qcom_spm: Detach state machine from main SPM handling")
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/cpuidle/cpuidle-qcom-spm.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/cpuidle/cpuidle-qcom-spm.c b/drivers/cpuidle/cpuidle-qcom-spm.c
index 5f386761b156..f60a4cf53642 100644
--- a/drivers/cpuidle/cpuidle-qcom-spm.c
+++ b/drivers/cpuidle/cpuidle-qcom-spm.c
@@ -96,20 +96,23 @@ static int spm_cpuidle_register(struct device *cpuidle_dev, int cpu)
return -ENODEV;
saw_node = of_parse_phandle(cpu_node, "qcom,saw", 0);
+ of_node_put(cpu_node);
if (!saw_node)
return -ENODEV;
pdev = of_find_device_by_node(saw_node);
of_node_put(saw_node);
- of_node_put(cpu_node);
if (!pdev)
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);
+ put_device(&pdev->dev);
if (!data->spm)
return -EINVAL;
--
2.49.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 1/2] cpuidle: qcom-spm: fix device and OF node leaks at probe
2025-09-08 15:22 ` [PATCH 1/2] " Johan Hovold
@ 2025-09-08 15:40 ` Konrad Dybcio
2025-09-10 11:36 ` Rafael J. Wysocki
0 siblings, 1 reply; 6+ messages in thread
From: Konrad Dybcio @ 2025-09-08 15:40 UTC (permalink / raw)
To: Johan Hovold, Rafael J. Wysocki, Daniel Lezcano
Cc: AngeloGioacchino Del Regno, linux-arm-msm, linux-pm, linux-kernel
On 9/8/25 5:22 PM, Johan Hovold wrote:
> Make sure to drop the reference to the saw device taken by
> of_find_device_by_node() after retrieving its driver data during
> probe().
>
> Also drop the reference to the CPU node sooner to avoid leaking it in
> case there is no saw node or device.
>
> Fixes: 60f3692b5f0b ("cpuidle: qcom_spm: Detach state machine from main SPM handling")
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Konrad
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 1/2] cpuidle: qcom-spm: fix device and OF node leaks at probe
2025-09-08 15:40 ` Konrad Dybcio
@ 2025-09-10 11:36 ` Rafael J. Wysocki
0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2025-09-10 11:36 UTC (permalink / raw)
To: Konrad Dybcio
Cc: Johan Hovold, Rafael J. Wysocki, Daniel Lezcano,
AngeloGioacchino Del Regno, linux-arm-msm, linux-pm, linux-kernel
On Mon, Sep 8, 2025 at 5:40 PM Konrad Dybcio
<konrad.dybcio@oss.qualcomm.com> wrote:
>
> On 9/8/25 5:22 PM, Johan Hovold wrote:
> > Make sure to drop the reference to the saw device taken by
> > of_find_device_by_node() after retrieving its driver data during
> > probe().
> >
> > Also drop the reference to the CPU node sooner to avoid leaking it in
> > case there is no saw node or device.
> >
> > Fixes: 60f3692b5f0b ("cpuidle: qcom_spm: Detach state machine from main SPM handling")
> > Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> > ---
>
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Applied as 6.18 material along with the [2/2], thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] cpuidle: qcom-spm: drop unnecessary initialisations
2025-09-08 15:22 [PATCH 0/2] cpuidle: qcom-spm: fix device and OF node leaks at probe Johan Hovold
2025-09-08 15:22 ` [PATCH 1/2] " Johan Hovold
@ 2025-09-08 15:22 ` Johan Hovold
2025-09-08 15:41 ` Konrad Dybcio
1 sibling, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2025-09-08 15:22 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano
Cc: AngeloGioacchino Del Regno, linux-arm-msm, linux-pm, linux-kernel,
Johan Hovold
Drop the unnecessary initialisations of the platform device and driver
data pointers which are assigned on first use when registering the
cpuidle device during probe.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/cpuidle/cpuidle-qcom-spm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cpuidle/cpuidle-qcom-spm.c b/drivers/cpuidle/cpuidle-qcom-spm.c
index f60a4cf53642..7ab6f68b96a8 100644
--- a/drivers/cpuidle/cpuidle-qcom-spm.c
+++ b/drivers/cpuidle/cpuidle-qcom-spm.c
@@ -86,9 +86,9 @@ static const struct of_device_id qcom_idle_state_match[] = {
static int spm_cpuidle_register(struct device *cpuidle_dev, int cpu)
{
- struct platform_device *pdev = NULL;
+ struct platform_device *pdev;
struct device_node *cpu_node, *saw_node;
- struct cpuidle_qcom_spm_data *data = NULL;
+ struct cpuidle_qcom_spm_data *data;
int ret;
cpu_node = of_cpu_device_node_get(cpu);
--
2.49.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-09-10 11:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-08 15:22 [PATCH 0/2] cpuidle: qcom-spm: fix device and OF node leaks at probe Johan Hovold
2025-09-08 15:22 ` [PATCH 1/2] " Johan Hovold
2025-09-08 15:40 ` Konrad Dybcio
2025-09-10 11:36 ` Rafael J. Wysocki
2025-09-08 15:22 ` [PATCH 2/2] cpuidle: qcom-spm: drop unnecessary initialisations Johan Hovold
2025-09-08 15:41 ` Konrad Dybcio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox