summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>2015-09-01 08:44:05 +0300
committerMark Brown <broonie@kernel.org>2015-09-01 16:10:50 +0300
commit51d2eeef1d958ef6834b24f548194f5acea0f499 (patch)
tree0beae9e8d582f3dd6045777369ceae270225f354 /sound
parentbc0195aad0daa2ad5b0d76cce22b167bc3435590 (diff)
downloadlinux-51d2eeef1d958ef6834b24f548194f5acea0f499.tar.xz
ASoC: wm0010: fix memory leak
We were aborting if the kzalloc of img_swap fails but without freeing the already allocated out. Similarly we were aborting if spi_sync fails without releasing out and img_swap. Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/wm0010.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c
index 6560a66b3f35..9d370a45abe8 100644
--- a/sound/soc/codecs/wm0010.c
+++ b/sound/soc/codecs/wm0010.c
@@ -672,8 +672,10 @@ static int wm0010_boot(struct snd_soc_codec *codec)
}
img_swap = kzalloc(len, GFP_KERNEL | GFP_DMA);
- if (!img_swap)
+ if (!img_swap) {
+ kfree(out);
goto abort;
+ }
/* We need to re-order for 0010 */
byte_swap_64((u64 *)&pll_rec, img_swap, len);
@@ -690,6 +692,8 @@ static int wm0010_boot(struct snd_soc_codec *codec)
ret = spi_sync(spi, &m);
if (ret != 0) {
dev_err(codec->dev, "First PLL write failed: %d\n", ret);
+ kfree(img_swap);
+ kfree(out);
goto abort;
}
@@ -697,6 +701,8 @@ static int wm0010_boot(struct snd_soc_codec *codec)
ret = spi_sync(spi, &m);
if (ret != 0) {
dev_err(codec->dev, "Second PLL write failed: %d\n", ret);
+ kfree(img_swap);
+ kfree(out);
goto abort;
}