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

Johan Hovold posted 2 patches 5 days, 7 hours ago
[PATCH 2/2] soc: qcom: pbs: fix device leak on lookup
Posted by Johan Hovold 5 days, 7 hours ago
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
Re: [PATCH 2/2] soc: qcom: pbs: fix device leak on lookup
Posted by Markus Elfring 5 days, 3 hours ago
> 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