Commit 1b3ed70a authored by Felipe Pena's avatar Felipe Pena Committed by Mark Brown

ASoC: fsl: Fix memory leak in imx-audmux.c

When audmux_clk is used and clk_prepare_enable function succeed,
the memory alloc'd to buf variable is leaked
Signed-off-by: default avatarFelipe Pena <felipensp@gmail.com>
Reviewed-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 8e9c4aa4
...@@ -66,13 +66,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf, ...@@ -66,13 +66,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
ssize_t ret; ssize_t ret;
char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); char *buf;
int port = (int)file->private_data; int port = (int)file->private_data;
u32 pdcr, ptcr; u32 pdcr, ptcr;
if (!buf)
return -ENOMEM;
if (audmux_clk) { if (audmux_clk) {
ret = clk_prepare_enable(audmux_clk); ret = clk_prepare_enable(audmux_clk);
if (ret) if (ret)
...@@ -85,6 +82,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf, ...@@ -85,6 +82,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
if (audmux_clk) if (audmux_clk)
clk_disable_unprepare(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", ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n",
pdcr, ptcr); pdcr, ptcr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment