alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: wm_adsp: fix possible memory leak in wm_adsp_load_coeff()
@ 2013-03-11 16:23 Wei Yongjun
  2013-03-12 18:42 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2013-03-11 16:23 UTC (permalink / raw)
  To: broonie, lgirdwood, perex, tiwai
  Cc: yongjun_wei, patches, alsa-devel, linux-kernel

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

'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 <yongjun_wei@trendmicro.com.cn>
---
 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)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASoC: wm_adsp: fix possible memory leak in wm_adsp_load_coeff()
  2013-03-11 16:23 [PATCH] ASoC: wm_adsp: fix possible memory leak in wm_adsp_load_coeff() Wei Yongjun
@ 2013-03-12 18:42 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-03-12 18:42 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: alsa-devel, tiwai, linux-kernel, patches, lgirdwood, yongjun_wei


[-- Attachment #1.1: Type: text/plain, Size: 294 bytes --]

On Tue, Mar 12, 2013 at 12:23:15AM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> '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.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-12 18:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-11 16:23 [PATCH] ASoC: wm_adsp: fix possible memory leak in wm_adsp_load_coeff() Wei Yongjun
2013-03-12 18:42 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).