Skip to contentSkip to conversation

soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem

PATCH Applied Miaoqian Lin 2 participants 4 messages Jan 7, 2022 – Mar 1, 2022

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

PATCH 1/1 soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem

The reference taken by 'of_find_device_by_node()' must be released when not needed anymore.
Add the corresponding 'put_device()' in the error handling path.

Fixes 01f937ffc468 ("soc: qcom: ocmem: don't return NULL in of_get_ocmem")
---
 drivers/soc/qcom/ocmem.c | 1 +
 1 file changed, 1 insertion(+)
drivers/soc/qcom/ocmem.c +1 -0
index d2dacbbaafbd..97fd24c178f8 100644
@@ -206,6 +206,7 @@ struct ocmem *of_get_ocmem(struct device *dev)
 	ocmem = platform_get_drvdata(pdev);
 	if (!ocmem) {
 		dev_err(dev, "Cannot get ocmem\n");
+		put_device(&pdev->dev);
 		return ERR_PTR(-ENODEV);
 	}
 	return ocmem;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 6 lines · Miaoqian Lin

The reference taken by 'of_find_device_by_node()' must be released when not needed anymore.
Add the corresponding 'put_device()' in the error handling path.

Fixes 01f937ffc468 ("soc: qcom: ocmem: don't return NULL in of_get_ocmem")

Your patch solves the particular problem, so I'm applying it.

But it seems that we never release pdev in the case of successfully return the ocmem object either... So there's more to improve here.

Regards,
Bjorn

Quoted 19 lines
---
 drivers/soc/qcom/ocmem.c | 1 +
 1 file changed, 1 insertion(+)
drivers/soc/qcom/ocmem.c +1 -0
index d2dacbbaafbd..97fd24c178f8 100644
@@ -206,6 +206,7 @@ struct ocmem *of_get_ocmem(struct device *dev)
 	ocmem = platform_get_drvdata(pdev);
 	if (!ocmem) {
 		dev_err(dev, "Cannot get ocmem\n");
+		put_device(&pdev->dev);
 		return ERR_PTR(-ENODEV);
 	}
 	return ocmem;
Signature · 1 line
2.17.1
#2 lore raw

Hi, Andersson:

Quoted 5 lines

Your patch solves the particular problem, so I'm applying it.

But it seems that we never release pdev in the case of successfully return the ocmem object either... So there's more to improve here.

Thanks for your time. Should I submit another patch to release pdev in the regular path?

Quoted 18 lines
Quoted 18 lines
 drivers/soc/qcom/ocmem.c | 1 +
 1 file changed, 1 insertion(+)
drivers/soc/qcom/ocmem.c +1 -0
index d2dacbbaafbd..97fd24c178f8 100644
@@ -206,6 +206,7 @@ struct ocmem *of_get_ocmem(struct device *dev)
 	ocmem = platform_get_drvdata(pdev);
 	if (!ocmem) {
 		dev_err(dev, "Cannot get ocmem\n");
+		put_device(&pdev->dev);
 		return ERR_PTR(-ENODEV);
 	}
 	return ocmem;
Signature · 1 line
2.17.1
#3 lore raw

Re: (subset) [PATCH] soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem

In reply to Miaoqian Lin
Quoted 5 lines · Miaoqian Lin

The reference taken by 'of_find_device_by_node()' must be released when not needed anymore.
Add the corresponding 'put_device()' in the error handling path.

Applied, thanks!

[1/1] soc: qcom: ocmem: Fix missing put_device() call in of_get_ocmem

      commit: 0ff027027e05a866491bbb53494f0e2a61354c85

Best regards,

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