diff mbox series

watchdog: rti_wdt: Fix an OF node leak in rti_wdt_probe()

Message ID 20250105111718.4184192-1-joe@pf.is.s.u-tokyo.ac.jp
State New
Headers show
Series watchdog: rti_wdt: Fix an OF node leak in rti_wdt_probe() | expand

Commit Message

Joe Hattori Jan. 5, 2025, 11:17 a.m. UTC
rti_wdt_probe() does not release the OF node reference obtained by
of_parse_phandle(). Add a of_node_put() call.

This was found by an experimental verification tool that I am
developing. Due to the lack of the actual device, no runtime test was
able to be performed.

Fixes: f20ca595ae23 ("watchdog:rit_wdt: Add support for WDIOF_CARDRESET")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
---
 drivers/watchdog/rti_wdt.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Guenter Roeck Jan. 6, 2025, 4:57 p.m. UTC | #1
On 1/5/25 03:17, Joe Hattori wrote:
> rti_wdt_probe() does not release the OF node reference obtained by
> of_parse_phandle(). Add a of_node_put() call.
> 
> This was found by an experimental verification tool that I am
> developing. Due to the lack of the actual device, no runtime test was
> able to be performed.
> 
> Fixes: f20ca595ae23 ("watchdog:rit_wdt: Add support for WDIOF_CARDRESET")
> Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/watchdog/rti_wdt.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
> index 58c9445c0f88..255ece133576 100644
> --- a/drivers/watchdog/rti_wdt.c
> +++ b/drivers/watchdog/rti_wdt.c
> @@ -301,6 +301,7 @@ static int rti_wdt_probe(struct platform_device *pdev)
>   	node = of_parse_phandle(pdev->dev.of_node, "memory-region", 0);
>   	if (node) {
>   		ret = of_address_to_resource(node, 0, &res);
> +		of_node_put(node);
>   		if (ret) {
>   			dev_err(dev, "No memory address assigned to the region.\n");
>   			goto err_iomap;
diff mbox series

Patch

diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
index 58c9445c0f88..255ece133576 100644
--- a/drivers/watchdog/rti_wdt.c
+++ b/drivers/watchdog/rti_wdt.c
@@ -301,6 +301,7 @@  static int rti_wdt_probe(struct platform_device *pdev)
 	node = of_parse_phandle(pdev->dev.of_node, "memory-region", 0);
 	if (node) {
 		ret = of_address_to_resource(node, 0, &res);
+		of_node_put(node);
 		if (ret) {
 			dev_err(dev, "No memory address assigned to the region.\n");
 			goto err_iomap;