asoc: tegra: fix Coverity issues of resource leak
Deepak Nibade [Thu, 25 Jul 2013 05:55:47 +0000 (10:55 +0530)]
- add kfree in error paths which can result into
  possible memory leak
  Coverity id : 23675
  Coverity id : 23676
  Coverity id : 23747

Bug 1329327

Change-Id: Ie2f27029cd3c72cf35f29877a4935f7b22887665
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/253227
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sumit Bhattacharya <sumitb@nvidia.com>

sound/soc/tegra/tegra_pcm.c
sound/soc/tegra/tegra_rt5639.c
sound/soc/tegra/tegra_rt5645.c

index 8f0f987..2b335a7 100644 (file)
@@ -80,6 +80,7 @@ static int tegra_pcm_open(struct snd_pcm_substream *substream)
        ret = snd_dmaengine_pcm_open_request_chan(substream, NULL, NULL);
        if (ret) {
                dev_err(dev, "dmaengine pcm open failed with err %d\n", ret);
+               kfree(prtd);
                return ret;
        }
 
index 5cc24cf..babd8af 100644 (file)
@@ -871,6 +871,8 @@ static int tegra_rt5639_driver_probe(struct platform_device *pdev)
        machine = kzalloc(sizeof(struct tegra_rt5639), GFP_KERNEL);
        if (!machine) {
                dev_err(&pdev->dev, "Can't allocate tegra_rt5639 struct\n");
+               if (np)
+                       kfree(pdata);
                return -ENOMEM;
        }
 
index a1d8afe..73ea79d 100644 (file)
@@ -877,6 +877,8 @@ static int tegra_rt5645_driver_probe(struct platform_device *pdev)
        machine = kzalloc(sizeof(struct tegra_rt5645), GFP_KERNEL);
        if (!machine) {
                dev_err(&pdev->dev, "Can't allocate tegra_rt5645 struct\n");
+               if (np)
+                       kfree(pdata);
                return -ENOMEM;
        }