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

mfd: max77620: 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.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Nishka Dasgupta and committed by
Lee Jones
197df18f 5f9e832c

+3 -1
+3 -1
drivers/mfd/max77620.c
··· 416 416 417 417 for_each_child_of_node(fps_np, fps_child) { 418 418 ret = max77620_config_fps(chip, fps_child); 419 - if (ret < 0) 419 + if (ret < 0) { 420 + of_node_put(fps_child); 420 421 return ret; 422 + } 421 423 } 422 424 423 425 config = chip->enable_global_lpm ? MAX77620_ONOFFCNFG2_SLP_LPM_MSK : 0;