Skip to contentSkip to conversation

memory: pl353-smc: Fix refcount leak bug in pl353_smc_probe()

PATCH Applied Liang He 2 participants 3 messages Jul 16, 2022 – Jul 19, 2022

Subsystems (2)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 memory: pl353-smc: Fix refcount leak bug in pl353_smc_probe()

The break of for_each_available_child_of_node() needs a correpsonding of_node_put() when the reference 'child'is not used anymore. Here we do not need to call of_node_put() in fail path as '!match' means no break.

While the of_platform_device_create() will created a new reference by 'child' but it has considered the refcounting.

Fixes fee10bd22678 ("memory: pl353: Add driver for arm pl353 static memory controller")
---
 drivers/memory/pl353-smc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/memory/pl353-smc.c +1 -0
index f84b98278745..d39ee7d06665 100644
@@ -122,6 +122,7 @@ static int pl353_smc_probe(struct amba_device *adev, const struct amba_id *id)
 	}
 
 	of_platform_device_create(child, NULL, &adev->dev);
+	of_node_put(child);
 
 	return 0;
 
Signature · 7 lines
2.25.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#2 lore raw
In reply to Liang He
Quoted 9 lines · Liang He

The break of for_each_available_child_of_node() needs a correpsonding of_node_put() when the reference 'child'is not used anymore. Here we do not need to call of_node_put() in fail path as '!match' means no break.

While the of_platform_device_create() will created a new reference by 'child' but it has considered the refcounting.

[...]

Applied, thanks!

[1/1] memory: pl353-smc: Fix refcount leak bug in pl353_smc_probe()

      https://git.kernel.org/krzk/linux-mem-ctrl/c/2d68c320aa14e5b494de698ce70ca6e6db40bc4b

Best regards,

Signature · 6 lines
Krzysztof Kozlowski <[email protected]>

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel