ASoC: sst_platform: fix memory leak
authorLu Guanqun <guanqun.lu@intel.com>
Tue, 6 Sep 2011 07:21:43 +0000 (15:21 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 8 Sep 2011 22:43:03 +0000 (15:43 -0700)
snd_pcm_hw_constraint_integer() could return -1, in this case, sst platform is
not opened successfully.  However the corresponding close callback isn't able
to be called later on to release these two allocated memories, thus resulting
in memory leak.

This patch moves the check for hardware contraints earlier, thus resolving this
issue.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/mid-x86/sst_platform.c

index af666ae671aed9fd2d6879da5e15b6b6dff1ee16..9925d20ab0a3dc441c99a5201329123108ea4812 100644 (file)
@@ -233,6 +233,10 @@ static int sst_platform_open(struct snd_pcm_substream *substream)
        pr_debug("sst_platform_open called\n");
 
        snd_soc_set_runtime_hwparams(substream, &sst_platform_pcm_hw);
+       ret_val = snd_pcm_hw_constraint_integer(runtime,
+                                               SNDRV_PCM_HW_PARAM_PERIODS);
+       if (ret_val < 0)
+               return ret_val;
 
        stream = kzalloc(sizeof(*stream), GFP_KERNEL);
        if (!stream)
@@ -260,8 +264,8 @@ static int sst_platform_open(struct snd_pcm_substream *substream)
                return ret_val;
        }
        runtime->private_data = stream;
-       return snd_pcm_hw_constraint_integer(runtime,
-                        SNDRV_PCM_HW_PARAM_PERIODS);
+
+       return 0;
 }
 
 static int sst_platform_close(struct snd_pcm_substream *substream)
This page took 0.037725 seconds and 5 git commands to generate.