Skip to content

Commit 5d24df3

Browse files
YuuoniyWim Van Sebroeck
authored andcommitted
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: bf90063 ("watchdog: ts4800: add driver for TS-4800 watchdog") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20220511114203.47420-1-linmq006@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
1 parent 9215a90 commit 5d24df3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/watchdog/ts4800_wdt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,16 @@ static int ts4800_wdt_probe(struct platform_device *pdev)
125125
ret = of_property_read_u32_index(np, "syscon", 1, &reg);
126126
if (ret < 0) {
127127
dev_err(dev, "no offset in syscon\n");
128+
of_node_put(syscon_np);
128129
return ret;
129130
}
130131

131132
/* allocate memory for watchdog struct */
132133
wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
133-
if (!wdt)
134+
if (!wdt) {
135+
of_node_put(syscon_np);
134136
return -ENOMEM;
137+
}
135138

136139
/* set regmap and offset to know where to write */
137140
wdt->feed_offset = reg;

0 commit comments

Comments
 (0)