Skip to content

Commit

Permalink
ASoC: sst_platform: fix memory leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lu Guanqun authored and Mark Brown committed Sep 8, 2011
1 parent 22be504 commit 283e42e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sound/soc/mid-x86/sst_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 283e42e

Please sign in to comment.