From: Nishka Dasgupta Date: Sat, 6 Jul 2019 13:34:22 +0000 (+0530) Subject: gpiolib: of: fix a memory leak in of_gpio_flags_quirks() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=89fea04c85e85f21ef4937611055abce82330d48;p=linux.git gpiolib: of: fix a memory leak in of_gpio_flags_quirks() Each iteration of for_each_child_of_node puts the previous node, but in the case of a break from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the break. Issue found with Coccinelle. Cc: Signed-off-by: Nishka Dasgupta [Bartosz: tweaked the commit message] Signed-off-by: Bartosz Golaszewski --- diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index f974075ff00e7..81ed50da3e9e1 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -161,6 +161,7 @@ static void of_gpio_flags_quirks(struct device_node *np, of_node_full_name(child)); *flags |= OF_GPIO_ACTIVE_LOW; } + of_node_put(child); break; } }