ASoC: wm_adsp: fix possible memory leak in wm_adsp_load_coeff()
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Mon, 11 Mar 2013 16:23:15 +0000 (00:23 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 12 Mar 2013 18:42:06 +0000 (18:42 +0000)
'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>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/wm_adsp.c

index f3f7e75f86280ef5160facc2a7f3cfa7972c6b91..9af1bddc4c62734d95dde719f37a8d2797d084ae 100644 (file)
@@ -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)