* [PATCH 0/2] soc: qcom: ocmem/pbs: fix device leaks on lookup
@ 2025-09-26 14:35 Johan Hovold
2025-09-26 14:35 ` [PATCH 1/2] soc: qcom: ocmem: fix device leak " Johan Hovold
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Johan Hovold @ 2025-09-26 14:35 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio; +Cc: linux-arm-msm, linux-kernel, Johan Hovold
This series fixes device leaks in the Qualcomm SoC drivers when looking
up platform devices using of_find_device_by_node().
Johan
Johan Hovold (2):
soc: qcom: ocmem: fix device leak on lookup
soc: qcom: pbs: fix device leak on lookup
drivers/soc/qcom/ocmem.c | 2 +-
drivers/soc/qcom/qcom-pbs.c | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
--
2.49.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] soc: qcom: ocmem: fix device leak on lookup
2025-09-26 14:35 [PATCH 0/2] soc: qcom: ocmem/pbs: fix device leaks on lookup Johan Hovold
@ 2025-09-26 14:35 ` Johan Hovold
2025-09-26 18:42 ` Markus Elfring
2025-09-26 21:08 ` Brian Masney
2025-09-26 14:35 ` [PATCH 2/2] soc: qcom: pbs: " Johan Hovold
2025-10-27 14:09 ` [PATCH 0/2] soc: qcom: ocmem/pbs: fix device leaks " Bjorn Andersson
2 siblings, 2 replies; 7+ messages in thread
From: Johan Hovold @ 2025-09-26 14:35 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio
Cc: linux-arm-msm, linux-kernel, Johan Hovold, stable, Brian Masney,
Miaoqian Lin
Make sure to drop the reference taken to the ocmem platform device when
looking up its driver data.
Note that holding a reference to a device does not prevent its driver
data from going away so there is no point in keeping the reference.
Also note that commit 0ff027027e05 ("soc: qcom: ocmem: Fix missing
put_device() call in of_get_ocmem") fixed the leak in a lookup error
path, but the reference is still leaking on success.
Fixes: 88c1e9404f1d ("soc: qcom: add OCMEM driver")
Cc: stable@vger.kernel.org # 5.5: 0ff027027e05
Cc: Brian Masney <bmasney@redhat.com>
Cc: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/soc/qcom/ocmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/soc/qcom/ocmem.c b/drivers/soc/qcom/ocmem.c
index 9c3bd37b6579..71130a2f62e9 100644
--- a/drivers/soc/qcom/ocmem.c
+++ b/drivers/soc/qcom/ocmem.c
@@ -202,9 +202,9 @@ struct ocmem *of_get_ocmem(struct device *dev)
}
ocmem = platform_get_drvdata(pdev);
+ put_device(&pdev->dev);
if (!ocmem) {
dev_err(dev, "Cannot get ocmem\n");
- put_device(&pdev->dev);
return ERR_PTR(-ENODEV);
}
return ocmem;
--
2.49.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] soc: qcom: pbs: fix device leak on lookup
2025-09-26 14:35 [PATCH 0/2] soc: qcom: ocmem/pbs: fix device leaks on lookup Johan Hovold
2025-09-26 14:35 ` [PATCH 1/2] soc: qcom: ocmem: fix device leak " Johan Hovold
@ 2025-09-26 14:35 ` Johan Hovold
2025-09-26 18:55 ` Markus Elfring
2025-10-27 14:09 ` [PATCH 0/2] soc: qcom: ocmem/pbs: fix device leaks " Bjorn Andersson
2 siblings, 1 reply; 7+ messages in thread
From: Johan Hovold @ 2025-09-26 14:35 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio
Cc: linux-arm-msm, linux-kernel, Johan Hovold, stable,
Anjelique Melendez
Make sure to drop the reference taken to the pbs platform device when
looking up its driver data.
Note that holding a reference to a device does not prevent its driver
data from going away so there is no point in keeping the reference.
Fixes: 5b2dd77be1d8 ("soc: qcom: add QCOM PBS driver")
Cc: stable@vger.kernel.org # 6.9
Cc: Anjelique Melendez <quic_amelende@quicinc.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/soc/qcom/qcom-pbs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/soc/qcom/qcom-pbs.c b/drivers/soc/qcom/qcom-pbs.c
index 1cc5d045f9dd..06b4a596e275 100644
--- a/drivers/soc/qcom/qcom-pbs.c
+++ b/drivers/soc/qcom/qcom-pbs.c
@@ -173,6 +173,8 @@ struct pbs_dev *get_pbs_client_device(struct device *dev)
return ERR_PTR(-EINVAL);
}
+ platform_device_put(pdev);
+
return pbs;
}
EXPORT_SYMBOL_GPL(get_pbs_client_device);
--
2.49.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] soc: qcom: ocmem: fix device leak on lookup
2025-09-26 14:35 ` [PATCH 1/2] soc: qcom: ocmem: fix device leak " Johan Hovold
@ 2025-09-26 18:42 ` Markus Elfring
2025-09-26 21:08 ` Brian Masney
1 sibling, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2025-09-26 18:42 UTC (permalink / raw)
To: Johan Hovold, linux-arm-msm, Bjorn Andersson, Konrad Dybcio
Cc: stable, LKML, Brian Masney, Miaoqian Lin
> Make sure to drop the reference taken to the ocmem platform device when
> looking up its driver data.
…
How do you think about to increase the application of scope-based resource management?
https://elixir.bootlin.com/linux/v6.17-rc7/source/include/linux/device.h#L1180
Regards,
Markus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] soc: qcom: pbs: fix device leak on lookup
2025-09-26 14:35 ` [PATCH 2/2] soc: qcom: pbs: " Johan Hovold
@ 2025-09-26 18:55 ` Markus Elfring
0 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2025-09-26 18:55 UTC (permalink / raw)
To: Johan Hovold, linux-arm-msm, Bjorn Andersson, Konrad Dybcio
Cc: stable, LKML, kernel-janitors, Anjelique Melendez
> Make sure to drop the reference taken to the pbs platform device when
> looking up its driver data.
…
How do you think about to increase the application of scope-based resource management?
Is there a need to improve the API description for platform_device_put()?
https://elixir.bootlin.com/linux/v6.17-rc7/source/drivers/base/platform.c#L543-L547
Regards,
Markus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] soc: qcom: ocmem: fix device leak on lookup
2025-09-26 14:35 ` [PATCH 1/2] soc: qcom: ocmem: fix device leak " Johan Hovold
2025-09-26 18:42 ` Markus Elfring
@ 2025-09-26 21:08 ` Brian Masney
1 sibling, 0 replies; 7+ messages in thread
From: Brian Masney @ 2025-09-26 21:08 UTC (permalink / raw)
To: Johan Hovold
Cc: Bjorn Andersson, Konrad Dybcio, linux-arm-msm, linux-kernel,
stable, Miaoqian Lin
On Fri, Sep 26, 2025 at 04:35:10PM +0200, Johan Hovold wrote:
> Make sure to drop the reference taken to the ocmem platform device when
> looking up its driver data.
>
> Note that holding a reference to a device does not prevent its driver
> data from going away so there is no point in keeping the reference.
>
> Also note that commit 0ff027027e05 ("soc: qcom: ocmem: Fix missing
> put_device() call in of_get_ocmem") fixed the leak in a lookup error
> path, but the reference is still leaking on success.
>
> Fixes: 88c1e9404f1d ("soc: qcom: add OCMEM driver")
> Cc: stable@vger.kernel.org # 5.5: 0ff027027e05
> Cc: Brian Masney <bmasney@redhat.com>
> Cc: Miaoqian Lin <linmq006@gmail.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Brian Masney <bmasney@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] soc: qcom: ocmem/pbs: fix device leaks on lookup
2025-09-26 14:35 [PATCH 0/2] soc: qcom: ocmem/pbs: fix device leaks on lookup Johan Hovold
2025-09-26 14:35 ` [PATCH 1/2] soc: qcom: ocmem: fix device leak " Johan Hovold
2025-09-26 14:35 ` [PATCH 2/2] soc: qcom: pbs: " Johan Hovold
@ 2025-10-27 14:09 ` Bjorn Andersson
2 siblings, 0 replies; 7+ messages in thread
From: Bjorn Andersson @ 2025-10-27 14:09 UTC (permalink / raw)
To: Konrad Dybcio, Johan Hovold; +Cc: linux-arm-msm, linux-kernel
On Fri, 26 Sep 2025 16:35:09 +0200, Johan Hovold wrote:
> This series fixes device leaks in the Qualcomm SoC drivers when looking
> up platform devices using of_find_device_by_node().
>
> Johan
>
>
> Johan Hovold (2):
> soc: qcom: ocmem: fix device leak on lookup
> soc: qcom: pbs: fix device leak on lookup
>
> [...]
Applied, thanks!
[1/2] soc: qcom: ocmem: fix device leak on lookup
commit: b5c16ea57b030b8e9428ec726e26219dfe05c3d9
[2/2] soc: qcom: pbs: fix device leak on lookup
commit: 94124bf253d24b13e89c45618a168d5a1d8a61e7
Best regards,
--
Bjorn Andersson <andersson@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-10-27 14:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-26 14:35 [PATCH 0/2] soc: qcom: ocmem/pbs: fix device leaks on lookup Johan Hovold
2025-09-26 14:35 ` [PATCH 1/2] soc: qcom: ocmem: fix device leak " Johan Hovold
2025-09-26 18:42 ` Markus Elfring
2025-09-26 21:08 ` Brian Masney
2025-09-26 14:35 ` [PATCH 2/2] soc: qcom: pbs: " Johan Hovold
2025-09-26 18:55 ` Markus Elfring
2025-10-27 14:09 ` [PATCH 0/2] soc: qcom: ocmem/pbs: fix device leaks " Bjorn Andersson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox