Commit 5d24df3d authored by Miaoqian Lin's avatar Miaoqian Lin Committed by Wim Van Sebroeck

watchdog: ts4800_wdt: Fix refcount leak in ts4800_wdt_probe

of_parse_phandle() returns a node pointer with refcount
incremented, we should use of_node_put() on it when done.
Add  missing of_node_put() in some error paths.

Fixes: bf900639 ("watchdog: ts4800: add driver for TS-4800 watchdog")
Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20220511114203.47420-1-linmq006@gmail.comSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
parent 9215a90d
...@@ -125,13 +125,16 @@ static int ts4800_wdt_probe(struct platform_device *pdev) ...@@ -125,13 +125,16 @@ static int ts4800_wdt_probe(struct platform_device *pdev)
ret = of_property_read_u32_index(np, "syscon", 1, &reg); ret = of_property_read_u32_index(np, "syscon", 1, &reg);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "no offset in syscon\n"); dev_err(dev, "no offset in syscon\n");
of_node_put(syscon_np);
return ret; return ret;
} }
/* allocate memory for watchdog struct */ /* allocate memory for watchdog struct */
wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
if (!wdt) if (!wdt) {
of_node_put(syscon_np);
return -ENOMEM; return -ENOMEM;
}
/* set regmap and offset to know where to write */ /* set regmap and offset to know where to write */
wdt->feed_offset = reg; wdt->feed_offset = reg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment