Skip to content

Commit

Permalink
ASoC: fsl: Fix memory leak in imx-audmux.c
Browse files Browse the repository at this point in the history
When audmux_clk is used and clk_prepare_enable function succeed,
the memory alloc'd to buf variable is leaked

Signed-off-by: Felipe Pena <felipensp@gmail.com>
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Felipe Pena authored and Mark Brown committed Oct 14, 2013
1 parent 8e9c4aa commit 1b3ed70
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sound/soc/fsl/imx-audmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
ssize_t ret;
char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
char *buf;
int port = (int)file->private_data;
u32 pdcr, ptcr;

if (!buf)
return -ENOMEM;

if (audmux_clk) {
ret = clk_prepare_enable(audmux_clk);
if (ret)
Expand All @@ -85,6 +82,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
if (audmux_clk)
clk_disable_unprepare(audmux_clk);

buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!buf)
return -ENOMEM;

ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n",
pdcr, ptcr);

Expand Down

0 comments on commit 1b3ed70

Please sign in to comment.