Skip to content

Commit

Permalink
watchdog: ts4800_wdt: Fix refcount leak in ts4800_wdt_probe
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Guenter Roeck <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Wim Van Sebroeck <[email protected]>
  • Loading branch information
Yuuoniy authored and Wim Van Sebroeck committed May 21, 2022
1 parent 9215a90 commit 5d24df3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/watchdog/ts4800_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,16 @@ static int ts4800_wdt_probe(struct platform_device *pdev)
ret = of_property_read_u32_index(np, "syscon", 1, &reg);
if (ret < 0) {
dev_err(dev, "no offset in syscon\n");
of_node_put(syscon_np);
return ret;
}

/* allocate memory for watchdog struct */
wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
if (!wdt)
if (!wdt) {
of_node_put(syscon_np);
return -ENOMEM;
}

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

0 comments on commit 5d24df3

Please sign in to comment.