soc: qcom: ocmem/pbs: fix device leaks on lookup
cover soc: qcom: ocmem/pbs: fix device leaks on lookup
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(-)
Signature · 1 line
2.49.1
PATCH 1/2 soc: qcom: ocmem: fix device leak on lookup
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.
--- drivers/soc/qcom/ocmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/ocmem.c +1 -1
@@ -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;
Signature · 1 line
2.49.1
Re: [PATCH 1/2] soc: qcom: ocmem: fix device leak on lookup
Quoted 2 lines
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
Re: [PATCH 1/2] soc: qcom: ocmem: fix device leak on lookup
In reply to Johan HovoldQuoted 10 lines · Johan Hovold
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 missingput_device()call inof_get_ocmem") fixed the leak in a lookup error path, but the reference is still leaking on success.
Quoted 5 lines
Fixes 88c1e9404f1d ("soc: qcom: add OCMEM driver")Cc [email protected] # 5.5: 0ff027027e05Cc Brian Masney <[email protected]>Cc Miaoqian Lin <[email protected]>Signed-off-by Johan Hovold <[email protected]>
PATCH 2/2 soc: qcom: pbs: fix device leak on lookup
In reply to Johan HovoldMake 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.
--- drivers/soc/qcom/qcom-pbs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/soc/qcom/qcom-pbs.c +2 -0
@@ -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);
Signature · 1 line
2.49.1
Re: [PATCH 2/2] soc: qcom: pbs: fix device leak on lookup
Quoted 2 lines
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
Quoted 11 lines · 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[...]
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: 94124bf253d24b13e89c45618a168d5a1d8a61e7Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>