OSDN Git Service

ASoC: qcom: Fix of-node refcount unbalance to link->codec_of_node
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / sound / soc / qcom / apq8016_sbc.c
index 1efdf00..f2c71bc 100644 (file)
@@ -98,31 +98,34 @@ static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card)
 
                if (!cpu || !codec) {
                        dev_err(dev, "Can't find cpu/codec DT node\n");
-                       return ERR_PTR(-EINVAL);
+                       ret = -EINVAL;
+                       goto error;
                }
 
                link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0);
                if (!link->cpu_of_node) {
                        dev_err(card->dev, "error getting cpu phandle\n");
-                       return ERR_PTR(-EINVAL);
+                       ret = -EINVAL;
+                       goto error;
                }
 
                link->codec_of_node = of_parse_phandle(codec, "sound-dai", 0);
                if (!link->codec_of_node) {
                        dev_err(card->dev, "error getting codec phandle\n");
-                       return ERR_PTR(-EINVAL);
+                       ret = -EINVAL;
+                       goto error;
                }
 
                ret = snd_soc_of_get_dai_name(cpu, &link->cpu_dai_name);
                if (ret) {
                        dev_err(card->dev, "error getting cpu dai name\n");
-                       return ERR_PTR(ret);
+                       goto error;
                }
 
                ret = snd_soc_of_get_dai_name(codec, &link->codec_dai_name);
                if (ret) {
                        dev_err(card->dev, "error getting codec dai name\n");
-                       return ERR_PTR(ret);
+                       goto error;
                }
 
                link->platform_of_node = link->cpu_of_node;
@@ -132,15 +135,24 @@ static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card)
                ret = of_property_read_string(np, "link-name", &link->name);
                if (ret) {
                        dev_err(card->dev, "error getting codec dai_link name\n");
-                       return ERR_PTR(ret);
+                       goto error;
                }
 
                link->stream_name = link->name;
                link->init = apq8016_sbc_dai_init;
                link++;
+
+               of_node_put(cpu);
+               of_node_put(codec);
        }
 
        return data;
+
+ error:
+       of_node_put(np);
+       of_node_put(cpu);
+       of_node_put(codec);
+       return ERR_PTR(ret);
 }
 
 static int apq8016_sbc_platform_probe(struct platform_device *pdev)