Skip to content

Commit

Permalink
hwmon: (ltc2992) Put fwnode in error case during ->probe()
Browse files Browse the repository at this point in the history
In each iteration fwnode_for_each_available_child_node() bumps a reference
counting of a loop variable followed by dropping in on a next iteration,

Since in error case the loop is broken, we have to drop a reference count
by ourselves. Do it for port_fwnode in error case during ->probe().

Fixes: b0bd407 ("hwmon: (ltc2992) Add support")
Cc: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210510100136.3303142-1-andy.shevchenko@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Andy Shevchenko authored and Guenter Roeck committed May 10, 2021
1 parent 2d101db commit 8370e5b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/hwmon/ltc2992.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,11 +900,15 @@ static int ltc2992_parse_dt(struct ltc2992_state *st)

fwnode_for_each_available_child_node(fwnode, child) {
ret = fwnode_property_read_u32(child, "reg", &addr);
if (ret < 0)
if (ret < 0) {
fwnode_handle_put(child);
return ret;
}

if (addr > 1)
if (addr > 1) {
fwnode_handle_put(child);
return -EINVAL;
}

ret = fwnode_property_read_u32(child, "shunt-resistor-micro-ohms", &val);
if (!ret)
Expand Down

0 comments on commit 8370e5b

Please sign in to comment.