mfd: core: Add missing of_node_put for loop iteration
authorKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Fri, 28 May 2021 11:51:26 +0000 (07:51 -0400)
committerLee Jones <lee.jones@linaro.org>
Fri, 5 Nov 2021 14:40:25 +0000 (14:40 +0000)
Early exits from for_each_child_of_node() should decrement the
node reference counter.  Reported by Coccinelle:

  drivers/mfd/mfd-core.c:197:2-24: WARNING:
    Function "for_each_child_of_node" should have of_node_put() before goto around lines 209.

Fixes: c94bb233a9fe ("mfd: Make MFD core code Device Tree and IRQ domain aware")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20210528115126.18370-1-krzysztof.kozlowski@canonical.com
drivers/mfd/mfd-core.c

index 79f5c6a18815a9ee9ea22948416afbbe0f521587..684a011a63968843f87a91e43abef57fe954a3d1 100644 (file)
@@ -198,6 +198,7 @@ static int mfd_add_device(struct device *parent, int id,
                        if (of_device_is_compatible(np, cell->of_compatible)) {
                                /* Ignore 'disabled' devices error free */
                                if (!of_device_is_available(np)) {
+                                       of_node_put(np);
                                        ret = 0;
                                        goto fail_alias;
                                }
@@ -205,6 +206,7 @@ static int mfd_add_device(struct device *parent, int id,
                                ret = mfd_match_of_node_to_dev(pdev, np, cell);
                                if (ret == -EAGAIN)
                                        continue;
+                               of_node_put(np);
                                if (ret)
                                        goto fail_alias;