mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] memory: mtk-smi: add missing put_device() call in mtk_smi_device_link_common
@ 2022-06-01 12:01 Miaoqian Lin
  2022-06-06  9:16 ` Krzysztof Kozlowski
  2022-06-06  9:20 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Miaoqian Lin @ 2022-06-01 12:01 UTC (permalink / raw)
  To: Yong Wu, Krzysztof Kozlowski, Matthias Brugger, Ikjoon Jang,
	linux-mediatek, linux-kernel, linux-arm-kernel
  Cc: linmq006

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 paths.

Fixes: 4740475 ("memory: mtk-smi: Add device link for smi-sub-common")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
changes in v2:
- add put_device() in return path -ENODEV.

I don't add put_device in normal path(return 0) because it will set
*com_dev=&smi_com_pdev->dev; and escape to the caller.

v1 link:
https://lore.kernel.org/all/20211230084115.5375-1-linmq006@gmail.com/
---
 drivers/memory/mtk-smi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index 86a3d34f418e..4c5154e0bf00 100644
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -404,13 +404,16 @@ static int mtk_smi_device_link_common(struct device *dev, struct device **com_de
 	of_node_put(smi_com_node);
 	if (smi_com_pdev) {
 		/* smi common is the supplier, Make sure it is ready before */
-		if (!platform_get_drvdata(smi_com_pdev))
+		if (!platform_get_drvdata(smi_com_pdev)) {
+			put_device(&smi_com_pdev->dev);
 			return -EPROBE_DEFER;
+		}
 		smi_com_dev = &smi_com_pdev->dev;
 		link = device_link_add(dev, smi_com_dev,
 				       DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS);
 		if (!link) {
 			dev_err(dev, "Unable to link smi-common dev\n");
+			put_device(&smi_com_pdev->dev);
 			return -ENODEV;
 		}
 		*com_dev = smi_com_dev;
-- 
2.25.1


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

* Re: [PATCH v2] memory: mtk-smi: add missing put_device() call in mtk_smi_device_link_common
  2022-06-01 12:01 [PATCH v2] memory: mtk-smi: add missing put_device() call in mtk_smi_device_link_common Miaoqian Lin
@ 2022-06-06  9:16 ` Krzysztof Kozlowski
  2022-06-06  9:20 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2022-06-06  9:16 UTC (permalink / raw)
  To: Miaoqian Lin, Yong Wu, Matthias Brugger, Ikjoon Jang,
	linux-mediatek, linux-kernel, linux-arm-kernel

On 01/06/2022 14:01, Miaoqian Lin wrote:
> 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 paths.
> 
> Fixes: 4740475 ("memory: mtk-smi: Add device link for smi-sub-common")

This is not correct SHA. Read:
Documentation/process/submitting-patches.rst


Best regards,
Krzysztof

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

* Re: [PATCH v2] memory: mtk-smi: add missing put_device() call in mtk_smi_device_link_common
  2022-06-01 12:01 [PATCH v2] memory: mtk-smi: add missing put_device() call in mtk_smi_device_link_common Miaoqian Lin
  2022-06-06  9:16 ` Krzysztof Kozlowski
@ 2022-06-06  9:20 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2022-06-06  9:20 UTC (permalink / raw)
  To: Yong Wu, Miaoqian Lin, linux-mediatek, Matthias Brugger,
	linux-arm-kernel, Ikjoon Jang, linux-kernel
  Cc: Krzysztof Kozlowski

On Wed, 1 Jun 2022 16:01:18 +0400, Miaoqian Lin wrote:
> 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 paths.
> 
> 

Applied, thanks!

[1/1] memory: mtk-smi: add missing put_device() call in mtk_smi_device_link_common
      https://git.kernel.org/krzk/linux-mem-ctrl/c/038ae37c510fd57cbc543ac82db1e7b23b28557a

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

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

end of thread, other threads:[~2022-06-06  9:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01 12:01 [PATCH v2] memory: mtk-smi: add missing put_device() call in mtk_smi_device_link_common Miaoqian Lin
2022-06-06  9:16 ` Krzysztof Kozlowski
2022-06-06  9:20 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®