2013-03-11 16:23:18

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH] ASoC: wm_adsp: fix possible memory leak in wm_adsp_load_coeff()

From: Wei Yongjun <[email protected]>

'file' is malloced in wm_adsp_load_coeff() and should be freed
before leaving from the error handling cases, otherwise it will cause
memory leak.

Signed-off-by: Wei Yongjun <[email protected]>
---
sound/soc/codecs/wm_adsp.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index f3f7e75..9af1bdd 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -828,7 +828,8 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
&buf_list);
if (!buf) {
adsp_err(dsp, "Out of memory\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto out_fw;
}

adsp_dbg(dsp, "%s.%d: Writing %d bytes at %x\n",
@@ -865,7 +866,7 @@ out_fw:
wm_adsp_buf_free(&buf_list);
out:
kfree(file);
- return 0;
+ return ret;
}

int wm_adsp1_init(struct wm_adsp *adsp)


2013-03-12 18:42:30

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] ASoC: wm_adsp: fix possible memory leak in wm_adsp_load_coeff()

On Tue, Mar 12, 2013 at 12:23:15AM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <[email protected]>
>
> 'file' is malloced in wm_adsp_load_coeff() and should be freed
> before leaving from the error handling cases, otherwise it will cause
> memory leak.

Applied, thanks.


Attachments:
(No filename) (286.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments