diff options
author | Sudip Mukherjee <sudipm.mukherjee@gmail.com> | 2015-09-18 06:32:21 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-09-19 11:40:55 -0400 |
commit | f072f91aa7517386344476813ca0799e08fd0c35 (patch) | |
tree | 7b4dfdb8ef4a0288e0b4b30442b76a2dd562642f /sound/soc | |
parent | 2ace47be5a315def8f493ca77aa59c077ade30a1 (diff) |
ASoC: wm0010: fix error path
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>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/codecs/wm0010.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c index 7a1bc40538ca..76b2f88d9d9b 100644 --- a/sound/soc/codecs/wm0010.c +++ b/sound/soc/codecs/wm0010.c | |||
@@ -663,10 +663,8 @@ static int wm0010_boot(struct snd_soc_codec *codec) | |||
663 | } | 663 | } |
664 | 664 | ||
665 | img_swap = kzalloc(len, GFP_KERNEL | GFP_DMA); | 665 | img_swap = kzalloc(len, GFP_KERNEL | GFP_DMA); |
666 | if (!img_swap) { | 666 | if (!img_swap) |
667 | kfree(out); | 667 | goto abort_out; |
668 | goto abort; | ||
669 | } | ||
670 | 668 | ||
671 | /* We need to re-order for 0010 */ | 669 | /* We need to re-order for 0010 */ |
672 | byte_swap_64((u64 *)&pll_rec, img_swap, len); | 670 | byte_swap_64((u64 *)&pll_rec, img_swap, len); |
@@ -681,20 +679,16 @@ static int wm0010_boot(struct snd_soc_codec *codec) | |||
681 | spi_message_add_tail(&t, &m); | 679 | spi_message_add_tail(&t, &m); |
682 | 680 | ||
683 | ret = spi_sync(spi, &m); | 681 | ret = spi_sync(spi, &m); |
684 | if (ret != 0) { | 682 | if (ret) { |
685 | dev_err(codec->dev, "First PLL write failed: %d\n", ret); | 683 | dev_err(codec->dev, "First PLL write failed: %d\n", ret); |
686 | kfree(img_swap); | 684 | goto abort_swap; |
687 | kfree(out); | ||
688 | goto abort; | ||
689 | } | 685 | } |
690 | 686 | ||
691 | /* Use a second send of the message to get the return status */ | 687 | /* Use a second send of the message to get the return status */ |
692 | ret = spi_sync(spi, &m); | 688 | ret = spi_sync(spi, &m); |
693 | if (ret != 0) { | 689 | if (ret) { |
694 | dev_err(codec->dev, "Second PLL write failed: %d\n", ret); | 690 | dev_err(codec->dev, "Second PLL write failed: %d\n", ret); |
695 | kfree(img_swap); | 691 | goto abort_swap; |
696 | kfree(out); | ||
697 | goto abort; | ||
698 | } | 692 | } |
699 | 693 | ||
700 | p = (u32 *)out; | 694 | p = (u32 *)out; |
@@ -727,6 +721,10 @@ static int wm0010_boot(struct snd_soc_codec *codec) | |||
727 | 721 | ||
728 | return 0; | 722 | return 0; |
729 | 723 | ||
724 | abort_swap: | ||
725 | kfree(img_swap); | ||
726 | abort_out: | ||
727 | kfree(out); | ||
730 | abort: | 728 | abort: |
731 | /* Put the chip back into reset */ | 729 | /* Put the chip back into reset */ |
732 | wm0010_halt(codec); | 730 | wm0010_halt(codec); |