ASoC: odroidx2_max98090: Add missing of_node_put() calls
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Mon, 23 Jun 2014 13:28:36 +0000 (15:28 +0200)
committerChanho Park <chanho61.park@samsung.com>
Tue, 18 Nov 2014 02:59:52 +0000 (11:59 +0900)
Ensure the acquired references to the DT nodes are properly released
on error paths and upon the driver's removal.

Change-Id: I8ffff330041ad6d6adbc1afff3c85154e18dd85d
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
sound/soc/samsung/odroidx2_max98090.c

index 98caf93..1e5f09b 100644 (file)
@@ -80,6 +80,7 @@ static int odroidx2_audio_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct snd_soc_card *card = &odroidx2;
+       int ret;
 
        card->dev = &pdev->dev;
 
@@ -96,7 +97,8 @@ static int odroidx2_audio_probe(struct platform_device *pdev)
        if (!odroidx2_dai[0].cpu_of_node) {
                dev_err(&pdev->dev,
                        "Property 'samsung,i2s-controller' missing or invalid\n");
-               return -EINVAL;
+               ret = -EINVAL;
+               goto err_put_cod_n;
        }
 
        odroidx2_dai[0].platform_of_node = odroidx2_dai[0].cpu_of_node;
@@ -104,7 +106,19 @@ static int odroidx2_audio_probe(struct platform_device *pdev)
        /* Configure the secondary audio interface with the same codec dai */
        odroidx2_dai[1].codec_of_node = odroidx2_dai[0].codec_of_node;
 
-       return snd_soc_register_card(card);
+       ret = snd_soc_register_card(card);
+       if (ret) {
+               dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret);
+               goto err_put_cpu_n;
+       }
+
+       return 0;
+
+err_put_cpu_n:
+       of_node_put((struct device_node *)odroidx2_dai[0].cpu_of_node);
+err_put_cod_n:
+       of_node_put((struct device_node *)odroidx2_dai[0].codec_of_node);
+       return ret;
 }
 
 static int odroidx2_audio_remove(struct platform_device *pdev)
@@ -113,6 +127,9 @@ static int odroidx2_audio_remove(struct platform_device *pdev)
 
        snd_soc_unregister_card(card);
 
+       of_node_put((struct device_node *)odroidx2_dai[0].cpu_of_node);
+       of_node_put((struct device_node *)odroidx2_dai[0].codec_of_node);
+
        return 0;
 }