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>
This commit is contained in:
parent
bc0195aad0
commit
51d2eeef1d
@ -672,8 +672,10 @@ static int wm0010_boot(struct snd_soc_codec *codec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
img_swap = kzalloc(len, GFP_KERNEL | GFP_DMA);
|
img_swap = kzalloc(len, GFP_KERNEL | GFP_DMA);
|
||||||
if (!img_swap)
|
if (!img_swap) {
|
||||||
|
kfree(out);
|
||||||
goto abort;
|
goto abort;
|
||||||
|
}
|
||||||
|
|
||||||
/* We need to re-order for 0010 */
|
/* We need to re-order for 0010 */
|
||||||
byte_swap_64((u64 *)&pll_rec, img_swap, len);
|
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);
|
ret = spi_sync(spi, &m);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
dev_err(codec->dev, "First PLL write failed: %d\n", ret);
|
dev_err(codec->dev, "First PLL write failed: %d\n", ret);
|
||||||
|
kfree(img_swap);
|
||||||
|
kfree(out);
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,6 +701,8 @@ static int wm0010_boot(struct snd_soc_codec *codec)
|
|||||||
ret = spi_sync(spi, &m);
|
ret = spi_sync(spi, &m);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
dev_err(codec->dev, "Second PLL write failed: %d\n", ret);
|
dev_err(codec->dev, "Second PLL write failed: %d\n", ret);
|
||||||
|
kfree(img_swap);
|
||||||
|
kfree(out);
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user