Skip to contentSkip to conversation

soc: qcom: ocmem/pbs: fix device leaks on lookup

PATCH Applied Johan Hovold 4 participants 7 messages Sep 26, 2025 – Oct 27, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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.

Fixes 88c1e9404f1d ("soc: qcom: add OCMEM driver")
Cc [email protected] # 5.5: 0ff027027e05
Cc Brian Masney <[email protected]>
Cc Miaoqian Lin <[email protected]>
---
 drivers/soc/qcom/ocmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/ocmem.c +1 -1
index 9c3bd37b6579..71130a2f62e9 100644
@@ -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
Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] soc: qcom: ocmem: fix device leak on lookup

In reply to Johan Hovold
Quoted 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 missing put_device() call in of_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: 0ff027027e05
Cc Brian Masney <[email protected]>
Cc Miaoqian Lin <[email protected]>
#4 lore raw

PATCH 2/2 soc: qcom: pbs: fix device leak on lookup

In reply to Johan Hovold

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 Anjelique Melendez <[email protected]>
---
 drivers/soc/qcom/qcom-pbs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/soc/qcom/qcom-pbs.c +2 -0
index 1cc5d045f9dd..06b4a596e275 100644
@@ -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
maintainer Applied
#6 lore raw
In reply to Johan Hovold
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: 94124bf253d24b13e89c45618a168d5a1d8a61e7

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>