* [PATCH 1/2] soc: qcom: ocmem: fix device leak on lookup [not found] <20250926143511.6715-1-johan@kernel.org> @ 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 1 sibling, 2 replies; 5+ 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] 5+ 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 on lookup Johan Hovold @ 2025-09-26 18:42 ` Markus Elfring 2025-09-26 21:08 ` Brian Masney 1 sibling, 0 replies; 5+ 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] 5+ 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 on lookup Johan Hovold 2025-09-26 18:42 ` Markus Elfring @ 2025-09-26 21:08 ` Brian Masney 1 sibling, 0 replies; 5+ 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] 5+ messages in thread
* [PATCH 2/2] soc: qcom: pbs: fix device leak on lookup [not found] <20250926143511.6715-1-johan@kernel.org> 2025-09-26 14:35 ` [PATCH 1/2] soc: qcom: ocmem: fix device leak on lookup Johan Hovold @ 2025-09-26 14:35 ` Johan Hovold 2025-09-26 18:55 ` Markus Elfring 1 sibling, 1 reply; 5+ 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] 5+ 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; 5+ 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] 5+ messages in thread
end of thread, other threads:[~2025-09-26 21:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250926143511.6715-1-johan@kernel.org>
2025-09-26 14:35 ` [PATCH 1/2] soc: qcom: ocmem: fix device leak on lookup 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox