Skip to content

Commit

Permalink
ASoC: wm0010: fix memory leak
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Charles Keepax <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
sudipm-mukherjee authored and nkskjames committed Jan 13, 2016
1 parent 2bd2210 commit 197401d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sound/soc/codecs/wm0010.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -690,13 +692,17 @@ 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;
}

/* Use a second send of the message to get the return status */
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;
}

Expand Down

0 comments on commit 197401d

Please sign in to comment.