Skip to contentSkip to conversation

soc: mediatek: mtk-svs: Call of_node_put(np) only once in svs_get_subsys_device()

PATCH Applied Markus Elfring 2 participants 3 messages Sep 24, 2024 – Oct 2, 2024

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

PATCH 1/1 soc: mediatek: mtk-svs: Call of_node_put(np) only once in svs_get_subsys_device()

From: Markus Elfring <[email protected]>
Date: Tue, 24 Sep 2024 20:00:09 +0200

An of_node_put(np) call was immediately used after a pointer check for a of_find_device_by_node() call in this function implementation. Thus call such a function only once instead directly before the check.

This issue was transformed by using the Coccinelle software.

---
 drivers/soc/mediatek/mtk-svs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/soc/mediatek/mtk-svs.c +1 -3
index 9a91298c1253..7c349a94b45c 100644
@@ -2133,14 +2133,12 @@ static struct device *svs_get_subsys_device(struct svs_platform *svsp,
 	}
 
 	pdev = of_find_device_by_node(np);
+	of_node_put(np);
 	if (!pdev) {
-		of_node_put(np);
 		dev_err(svsp->dev, "cannot find pdev by %s\n", node_name);
 		return ERR_PTR(-ENXIO);
 	}
 
-	of_node_put(np);
-
 	return &pdev->dev;
 }
 

--
2.46.1

maintainer Reviewed-by on v1 1/1
#1 lore raw

Il 24/09/24 20:08, Markus Elfring ha scritto:

Quoted 10 lines

From: Markus Elfring <[email protected]>
Date: Tue, 24 Sep 2024 20:00:09 +0200

An of_node_put(np) call was immediately used after a pointer check for a of_find_device_by_node() call in this function implementation. Thus call such a function only once instead directly before the check.

This issue was transformed by using the Coccinelle software.

Quoted 27 lines
---
  drivers/soc/mediatek/mtk-svs.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/soc/mediatek/mtk-svs.c +1 -4
index 9a91298c1253..7c349a94b45c 100644
@@ -2133,14 +2133,12 @@ static struct device *svs_get_subsys_device(struct svs_platform *svsp,
  	}
 
  	pdev = of_find_device_by_node(np);
+	of_node_put(np);
  	if (!pdev) {
-		of_node_put(np);
  		dev_err(svsp->dev, "cannot find pdev by %s\n", node_name);
  		return ERR_PTR(-ENXIO);
  	}
 
-	of_node_put(np);
-
  	return &pdev->dev;
  }
 
--

2.46.1

maintainer Applied
#2 lore raw
In reply to Markus Elfring
Quoted 8 lines · Markus Elfring

An of_node_put(np) call was immediately used after a pointer check for a of_find_device_by_node() call in this function implementation. Thus call such a function only once instead directly before the check.

This issue was transformed by using the Coccinelle software.

[...]

Applied to v6.12-next/soc, thanks!

[1/1] soc: mediatek: mtk-svs: Call of_node_put(np) only once in svs_get_subsys_device()

      https://git.kernel.org/mediatek/c/1ee71494

Cheers,
Angelo