Skip to contentSkip to conversation

memory: mtk-smi: add missing put_device() call in mtk_smi_device_link_common

PATCH Superseded Miaoqian Lin 2 participants 2 messages Dec 30, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memory: mtk-smi: add missing put_device() call in mtk_smi_device_link_common

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")
---
 drivers/memory/mtk-smi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/memory/mtk-smi.c +3 -1
index e201e5976f34..2131f2c9e7ed 100644
@@ -386,8 +386,10 @@ 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);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 15 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 paths.

Fixes 4740475 ("memory: mtk-smi: Add device link for smi-sub-common")
---
 drivers/memory/mtk-smi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/memory/mtk-smi.c +0 -0
index e201e5976f34..2131f2c9e7ed 100644

drivers/memory/mtk-smi.c static int mtk_smi_device_link_common(struct device *dev, struct device **com_de · line 392

Quoted 8 lines
drivers/memory/mtk-smi.c +3 -1
@@ -386,8 +386,10 @@ 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;
+		}

What about other return paths (-ENODEV, 0)?

Best regards,
Krzysztof