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

Input: sun4i-lradc-keys - add of_node_put() before return

Each iteration of for_each_child_of_node puts the previous
node, but in the case of a return from the middle of the loop, there is
no put, thus causing a memory leak. Hence add an of_node_put before the
return in three places.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Nishka Dasgupta and committed by
Dmitry Torokhov
071cfc43 1976d7d2

+3
+3
drivers/input/keyboard/sun4i-lradc-keys.c
··· 207 207 error = of_property_read_u32(pp, "channel", &channel); 208 208 if (error || channel != 0) { 209 209 dev_err(dev, "%pOFn: Inval channel prop\n", pp); 210 + of_node_put(pp); 210 211 return -EINVAL; 211 212 } 212 213 213 214 error = of_property_read_u32(pp, "voltage", &map->voltage); 214 215 if (error) { 215 216 dev_err(dev, "%pOFn: Inval voltage prop\n", pp); 217 + of_node_put(pp); 216 218 return -EINVAL; 217 219 } 218 220 219 221 error = of_property_read_u32(pp, "linux,code", &map->keycode); 220 222 if (error) { 221 223 dev_err(dev, "%pOFn: Inval linux,code prop\n", pp); 224 + of_node_put(pp); 222 225 return -EINVAL; 223 226 } 224 227