]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
pinctrl: samsung: Fix device node refcount leaks in Exynos wakeup controller init
authorKrzysztof Kozlowski <krzk@kernel.org>
Mon, 5 Aug 2019 16:27:07 +0000 (18:27 +0200)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:23:04 +0000 (14:23 -0300)
BugLink: https://bugs.launchpad.net/bugs/1857158
commit 5c7f48dd14e892e3e920dd6bbbd52df79e1b3b41 upstream.

In exynos_eint_wkup_init() the for_each_child_of_node() loop is used
with a break to find a matching child node.  Although each iteration of
for_each_child_of_node puts the previous node, but early exit from loop
misses it.  This leads to leak of device node.

Cc: <stable@vger.kernel.org>
Fixes: 43b169db1841 ("pinctrl: add exynos4210 specific extensions for samsung pinctrl driver")
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/pinctrl/samsung/pinctrl-exynos.c

index 1c534d823fd792ec276691d5bc7d23d9c233f743..b9197b793bbd59b94d05b4ce4f2cd586c8a249ea 100644 (file)
@@ -487,6 +487,7 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
                                bank->nr_pins, &exynos_eint_irqd_ops, bank);
                if (!bank->irq_domain) {
                        dev_err(dev, "wkup irq domain add failed\n");
+                       of_node_put(wkup_np);
                        return -ENXIO;
                }
 
@@ -500,8 +501,10 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 
                weint_data = devm_kzalloc(dev, bank->nr_pins
                                        * sizeof(*weint_data), GFP_KERNEL);
-               if (!weint_data)
+               if (!weint_data) {
+                       of_node_put(wkup_np);
                        return -ENOMEM;
+               }
 
                for (idx = 0; idx < bank->nr_pins; ++idx) {
                        irq = irq_of_parse_and_map(bank->of_node, idx);
@@ -518,10 +521,13 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
                }
        }
 
-       if (!muxed_banks)
+       if (!muxed_banks) {
+               of_node_put(wkup_np);
                return 0;
+       }
 
        irq = irq_of_parse_and_map(wkup_np, 0);
+       of_node_put(wkup_np);
        if (!irq) {
                dev_err(dev, "irq number for muxed EINTs not found\n");
                return 0;