mmc: atmel-mci: add missing of_node_put
authorJulia Lawall <Julia.Lawall@lip6.fr>
Sat, 15 Jul 2017 16:27:41 +0000 (18:27 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Wed, 30 Aug 2017 12:01:31 +0000 (14:01 +0200)
for_each_child_of_node performs an of_node_get on each iteration, so a
break out the loop requires an of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
local idexpression n;
expression e,e1;
iterator name for_each_child_of_node;
@@

 for_each_child_of_node(e1,n) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  break;
)
   ...
 }
... when != n
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/atmel-mci.c

index 53e30b0504b5d8bb150c00f3ba4595476970f7dc..dcd028760c25190651f0b2c3afd94239d137451e 100644 (file)
@@ -673,6 +673,7 @@ atmci_of_init(struct platform_device *pdev)
                if (slot_id >= ATMCI_MAX_NR_SLOTS) {
                        dev_warn(&pdev->dev, "can't have more than %d slots\n",
                                 ATMCI_MAX_NR_SLOTS);
+                       of_node_put(cnp);
                        break;
                }