summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNishka Dasgupta <nishkadg.linux@gmail.com>2019-07-06 19:04:22 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-07-28 08:28:36 +0200
commitf39659f4b3b4742310550a4225bfebf41117f378 (patch)
treeea6601634169b48dff7235799ba59df9fa415608
parent4528cbb9659195c82bf80745e5abdc14e9ecbb79 (diff)
downloadlinux-stable-f39659f4b3b4742310550a4225bfebf41117f378.tar.gz
linux-stable-f39659f4b3b4742310550a4225bfebf41117f378.tar.bz2
linux-stable-f39659f4b3b4742310550a4225bfebf41117f378.zip
gpiolib: of: fix a memory leak in of_gpio_flags_quirks()
commit 89fea04c85e85f21ef4937611055abce82330d48 upstream. 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: <stable@vger.kernel.org> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com> [Bartosz: tweaked the commit message] Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/gpio/gpiolib-of.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 6a3ec575a404..6779853f166b 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -155,6 +155,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;
}
}