Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (ltc2992) Put fwnode in error case during ->probe()

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: b0bd407e94b0 ("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>

authored by

Andy Shevchenko and committed by
Guenter Roeck
8370e5b0 2d101db3

+6 -2
+6 -2
drivers/hwmon/ltc2992.c
··· 900 900 901 901 fwnode_for_each_available_child_node(fwnode, child) { 902 902 ret = fwnode_property_read_u32(child, "reg", &addr); 903 - if (ret < 0) 903 + if (ret < 0) { 904 + fwnode_handle_put(child); 904 905 return ret; 906 + } 905 907 906 - if (addr > 1) 908 + if (addr > 1) { 909 + fwnode_handle_put(child); 907 910 return -EINVAL; 911 + } 908 912 909 913 ret = fwnode_property_read_u32(child, "shunt-resistor-micro-ohms", &val); 910 914 if (!ret)