Skip to content

Commit

Permalink
ASoC: wm0010: fix error path
Browse files Browse the repository at this point in the history
Fix the error path so that we can free the allocated memory on the error
path instead of releasing them individually on each error.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Sudip Mukherjee authored and Mark Brown committed Sep 19, 2015
1 parent 2ace47b commit f072f91
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions sound/soc/codecs/wm0010.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,10 +663,8 @@ static int wm0010_boot(struct snd_soc_codec *codec)
}

img_swap = kzalloc(len, GFP_KERNEL | GFP_DMA);
if (!img_swap) {
kfree(out);
goto abort;
}
if (!img_swap)
goto abort_out;

/* We need to re-order for 0010 */
byte_swap_64((u64 *)&pll_rec, img_swap, len);
Expand All @@ -681,20 +679,16 @@ static int wm0010_boot(struct snd_soc_codec *codec)
spi_message_add_tail(&t, &m);

ret = spi_sync(spi, &m);
if (ret != 0) {
if (ret) {
dev_err(codec->dev, "First PLL write failed: %d\n", ret);
kfree(img_swap);
kfree(out);
goto abort;
goto abort_swap;
}

/* Use a second send of the message to get the return status */
ret = spi_sync(spi, &m);
if (ret != 0) {
if (ret) {
dev_err(codec->dev, "Second PLL write failed: %d\n", ret);
kfree(img_swap);
kfree(out);
goto abort;
goto abort_swap;
}

p = (u32 *)out;
Expand Down Expand Up @@ -727,6 +721,10 @@ static int wm0010_boot(struct snd_soc_codec *codec)

return 0;

abort_swap:
kfree(img_swap);
abort_out:
kfree(out);
abort:
/* Put the chip back into reset */
wm0010_halt(codec);
Expand Down

0 comments on commit f072f91

Please sign in to comment.