ASoC: rsnd: add missing of_node_put
authorJulia Lawall <Julia.Lawall@lip6.fr>
Sat, 15 Jul 2017 07:19:07 +0000 (09:19 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 17 Jul 2017 14:39:51 +0000 (15:39 +0100)
for_each_child_of_node performs an of_node_get on each iteration, so a
jump out of 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;
identifier l;
@@

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

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sh/rcar/ctu.c
sound/soc/sh/rcar/dvc.c
sound/soc/sh/rcar/mix.c
sound/soc/sh/rcar/src.c
sound/soc/sh/rcar/ssi.c

index 4ba8f2fe7a4c47f08f046de4062e8ff7e9279cc4..e7f53f44165d78b423c56a1623bbc2cfe965e0e6 100644 (file)
@@ -394,13 +394,16 @@ int rsnd_ctu_probe(struct rsnd_priv *priv)
                clk = devm_clk_get(dev, name);
                if (IS_ERR(clk)) {
                        ret = PTR_ERR(clk);
+                       of_node_put(np);
                        goto rsnd_ctu_probe_done;
                }
 
                ret = rsnd_mod_init(priv, rsnd_mod_get(ctu), &rsnd_ctu_ops,
                                    clk, rsnd_mod_get_status, RSND_MOD_CTU, i);
-               if (ret)
+               if (ret) {
+                       of_node_put(np);
                        goto rsnd_ctu_probe_done;
+               }
 
                i++;
        }
index 99d2d9459e755a46f630b36f93611e88c4feeae6..1743ade3cc55563c04204b37b70d57254f41cae8 100644 (file)
@@ -380,13 +380,16 @@ int rsnd_dvc_probe(struct rsnd_priv *priv)
                clk = devm_clk_get(dev, name);
                if (IS_ERR(clk)) {
                        ret = PTR_ERR(clk);
+                       of_node_put(np);
                        goto rsnd_dvc_probe_done;
                }
 
                ret = rsnd_mod_init(priv, rsnd_mod_get(dvc), &rsnd_dvc_ops,
                                    clk, rsnd_mod_get_status, RSND_MOD_DVC, i);
-               if (ret)
+               if (ret) {
+                       of_node_put(np);
                        goto rsnd_dvc_probe_done;
+               }
 
                i++;
        }
index 195fc7bb22afb6519fb574af7b28832d2defda6b..6c4826c189a42d06eec412cf0086b9721faa28be 100644 (file)
@@ -168,13 +168,16 @@ int rsnd_mix_probe(struct rsnd_priv *priv)
                clk = devm_clk_get(dev, name);
                if (IS_ERR(clk)) {
                        ret = PTR_ERR(clk);
+                       of_node_put(np);
                        goto rsnd_mix_probe_done;
                }
 
                ret = rsnd_mod_init(priv, rsnd_mod_get(mix), &rsnd_mix_ops,
                                    clk, rsnd_mod_get_status, RSND_MOD_MIX, i);
-               if (ret)
+               if (ret) {
+                       of_node_put(np);
                        goto rsnd_mix_probe_done;
+               }
 
                i++;
        }
index 7aa239e28491525053d4dd957bf2cc4d2f4b056c..8e9a1de0ec251af2b1bb12195cc0ca442db4f80e 100644 (file)
@@ -581,20 +581,24 @@ int rsnd_src_probe(struct rsnd_priv *priv)
                src->irq = irq_of_parse_and_map(np, 0);
                if (!src->irq) {
                        ret = -EINVAL;
+                       of_node_put(np);
                        goto rsnd_src_probe_done;
                }
 
                clk = devm_clk_get(dev, name);
                if (IS_ERR(clk)) {
                        ret = PTR_ERR(clk);
+                       of_node_put(np);
                        goto rsnd_src_probe_done;
                }
 
                ret = rsnd_mod_init(priv, rsnd_mod_get(src),
                                    &rsnd_src_ops, clk, rsnd_mod_get_status,
                                    RSND_MOD_SRC, i);
-               if (ret)
+               if (ret) {
+                       of_node_put(np);
                        goto rsnd_src_probe_done;
+               }
 
 skip:
                i++;
index 46feddd78ee26f0e7fa90e40500914ef5b4edfe3..49cdc5e007b3667740a67128d3a19734e446a4b1 100644 (file)
@@ -1079,6 +1079,7 @@ int rsnd_ssi_probe(struct rsnd_priv *priv)
                clk = devm_clk_get(dev, name);
                if (IS_ERR(clk)) {
                        ret = PTR_ERR(clk);
+                       of_node_put(np);
                        goto rsnd_ssi_probe_done;
                }
 
@@ -1091,6 +1092,7 @@ int rsnd_ssi_probe(struct rsnd_priv *priv)
                ssi->irq = irq_of_parse_and_map(np, 0);
                if (!ssi->irq) {
                        ret = -EINVAL;
+                       of_node_put(np);
                        goto rsnd_ssi_probe_done;
                }
 
@@ -1101,8 +1103,10 @@ int rsnd_ssi_probe(struct rsnd_priv *priv)
 
                ret = rsnd_mod_init(priv, rsnd_mod_get(ssi), ops, clk,
                                    rsnd_ssi_get_status, RSND_MOD_SSI, i);
-               if (ret)
+               if (ret) {
+                       of_node_put(np);
                        goto rsnd_ssi_probe_done;
+               }
 
                i++;
        }