Skip to contentSkip to conversation

da8xx-cfgchip.c: replace of_node_put with __free improves cleanup

PATCH Applied David Hunter 3 participants 3 messages Jul 20, 2024 – Jul 29, 2024

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

PATCH 1/1 da8xx-cfgchip.c: replace of_node_put with __free improves cleanup

The use of the __free function allows the cleanup to be based on scope instead of on another function called later. This makes the cleanup automatic and less susceptible to errors later.

This code was compiled without errors or warnings.

---
 drivers/clk/davinci/da8xx-cfgchip.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clk/davinci/da8xx-cfgchip.c +1 -3
index ad2d0df43dc6..5ea0c072bfbe 100644
@@ -749,11 +749,9 @@ static int da8xx_cfgchip_probe(struct platform_device *pdev)
 
 	clk_init = device_get_match_data(dev);
 	if (clk_init) {
-		struct device_node *parent;
+		struct device_node *parent __free(device_node) = of_get_parent(dev->of_node);
 
-		parent = of_get_parent(dev->of_node);
 		regmap = syscon_node_to_regmap(parent);
-		of_node_put(parent);
 	} else if (pdev->id_entry && pdata) {
 		clk_init = (void *)pdev->id_entry->driver_data;
 		regmap = pdata->cfgchip;
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · David Hunter

The use of the __free function allows the cleanup to be based on scope instead of on another function called later. This makes the cleanup automatic and less susceptible to errors later.

This code was compiled without errors or warnings.

---

maintainer Applied
#2 lore raw
In reply to David Hunter

Quoting David Hunter (2024-07-20 08:24:47)

Quoted 8 lines

The use of the __free function allows the cleanup to be based on scope instead of on another function called later. This makes the cleanup automatic and less susceptible to errors later.

This code was compiled without errors or warnings.

---

Applied to clk-next