[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250926143511.6715-2-johan@kernel.org>
Date: Fri, 26 Sep 2025 16:35:10 +0200
From: Johan Hovold <johan@...nel.org>
To: Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konradybcio@...nel.org>
Cc: linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org,
Johan Hovold <johan@...nel.org>,
stable@...r.kernel.org,
Brian Masney <bmasney@...hat.com>,
Miaoqian Lin <linmq006@...il.com>
Subject: [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: stable@...r.kernel.org # 5.5: 0ff027027e05
Cc: Brian Masney <bmasney@...hat.com>
Cc: Miaoqian Lin <linmq006@...il.com>
Signed-off-by: Johan Hovold <johan@...nel.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
Powered by blists - more mailing lists