All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soc: qcom: ocmem: Fix refcount leak in of_get_ocmem
@ 2022-06-02  4:24 Miaoqian Lin
  2022-06-02  9:28 ` Brian Masney
  2022-07-03  3:56 ` (subset) " Bjorn Andersson
  0 siblings, 2 replies; 3+ messages in thread
From: Miaoqian Lin @ 2022-06-02  4:24 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Rob Clark, Brian Masney,
	linux-arm-msm, linux-kernel
  Cc: linmq006

of_parse_phandle() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.
of_node_put() will check NULL pointer.

Fixes: 88c1e9404f1d ("soc: qcom: add OCMEM driver")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/soc/qcom/ocmem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/soc/qcom/ocmem.c b/drivers/soc/qcom/ocmem.c
index 97fd24c178f8..c92d26b73e6f 100644
--- a/drivers/soc/qcom/ocmem.c
+++ b/drivers/soc/qcom/ocmem.c
@@ -194,14 +194,17 @@ struct ocmem *of_get_ocmem(struct device *dev)
 	devnode = of_parse_phandle(dev->of_node, "sram", 0);
 	if (!devnode || !devnode->parent) {
 		dev_err(dev, "Cannot look up sram phandle\n");
+		of_node_put(devnode);
 		return ERR_PTR(-ENODEV);
 	}
 
 	pdev = of_find_device_by_node(devnode->parent);
 	if (!pdev) {
 		dev_err(dev, "Cannot find device node %s\n", devnode->name);
+		of_node_put(devnode);
 		return ERR_PTR(-EPROBE_DEFER);
 	}
+	of_node_put(devnode);
 
 	ocmem = platform_get_drvdata(pdev);
 	if (!ocmem) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] soc: qcom: ocmem: Fix refcount leak in of_get_ocmem
  2022-06-02  4:24 [PATCH] soc: qcom: ocmem: Fix refcount leak in of_get_ocmem Miaoqian Lin
@ 2022-06-02  9:28 ` Brian Masney
  2022-07-03  3:56 ` (subset) " Bjorn Andersson
  1 sibling, 0 replies; 3+ messages in thread
From: Brian Masney @ 2022-06-02  9:28 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Andy Gross, Bjorn Andersson, Rob Clark, linux-arm-msm, linux-kernel

On Thu, Jun 02, 2022 at 08:24:30AM +0400, Miaoqian Lin wrote:
> of_parse_phandle() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when not need anymore.
> Add missing of_node_put() to avoid refcount leak.
> of_node_put() will check NULL pointer.
> 
> Fixes: 88c1e9404f1d ("soc: qcom: add OCMEM driver")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Reviewed-by: Brian Masney <masneyb@onstation.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: (subset) [PATCH] soc: qcom: ocmem: Fix refcount leak in of_get_ocmem
  2022-06-02  4:24 [PATCH] soc: qcom: ocmem: Fix refcount leak in of_get_ocmem Miaoqian Lin
  2022-06-02  9:28 ` Brian Masney
@ 2022-07-03  3:56 ` Bjorn Andersson
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2022-07-03  3:56 UTC (permalink / raw)
  To: Brian Masney, Andy Gross, linux-arm-msm, linux-kernel,
	Miaoqian Lin, Rob Clark

On Thu, 2 Jun 2022 08:24:30 +0400, Miaoqian Lin wrote:
> of_parse_phandle() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when not need anymore.
> Add missing of_node_put() to avoid refcount leak.
> of_node_put() will check NULL pointer.
> 
> 

Applied, thanks!

[1/1] soc: qcom: ocmem: Fix refcount leak in of_get_ocmem
      commit: 92a563fcf14b3093226fb36f12e9b5cf630c5a5d

Best regards,
-- 
Bjorn Andersson <bjorn.andersson@linaro.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-03  3:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02  4:24 [PATCH] soc: qcom: ocmem: Fix refcount leak in of_get_ocmem Miaoqian Lin
2022-06-02  9:28 ` Brian Masney
2022-07-03  3:56 ` (subset) " Bjorn Andersson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.