Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: arizona: Fix error path in codec probe

If we fail to add some DSPs or fail to add the controls we should call
wm_adsp2_codec_remove for all the cores we have already added. This
patch fixes this up on the wm5102 and wm5110.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Charles Keepax and committed by
Mark Brown
d90c6cc2 5ed68f0a

+14 -3
+6 -1
sound/soc/codecs/wm5102.c
··· 1879 1879 ret = snd_soc_add_codec_controls(codec, 1880 1880 arizona_adsp2_rate_controls, 1); 1881 1881 if (ret) 1882 - return ret; 1882 + goto err_adsp2_codec_probe; 1883 1883 1884 1884 arizona_init_spk(codec); 1885 1885 arizona_init_gpio(codec); ··· 1889 1889 priv->core.arizona->dapm = dapm; 1890 1890 1891 1891 return 0; 1892 + 1893 + err_adsp2_codec_probe: 1894 + wm_adsp2_codec_remove(&priv->core.adsp[0], codec); 1895 + 1896 + return ret; 1892 1897 } 1893 1898 1894 1899 static int wm5102_codec_remove(struct snd_soc_codec *codec)
+8 -2
sound/soc/codecs/wm5110.c
··· 1607 1607 for (i = 0; i < WM5110_NUM_ADSP; ++i) { 1608 1608 ret = wm_adsp2_codec_probe(&priv->core.adsp[i], codec); 1609 1609 if (ret) 1610 - return ret; 1610 + goto err_adsp2_codec_probe; 1611 1611 } 1612 1612 1613 1613 ret = snd_soc_add_codec_controls(codec, 1614 1614 arizona_adsp2_rate_controls, 1615 1615 WM5110_NUM_ADSP); 1616 1616 if (ret) 1617 - return ret; 1617 + goto err_adsp2_codec_probe; 1618 1618 1619 1619 snd_soc_dapm_disable_pin(dapm, "HAPTICS"); 1620 1620 1621 1621 return 0; 1622 + 1623 + err_adsp2_codec_probe: 1624 + for (--i; i >= 0; --i) 1625 + wm_adsp2_codec_remove(&priv->core.adsp[i], codec); 1626 + 1627 + return ret; 1622 1628 } 1623 1629 1624 1630 static int wm5110_codec_remove(struct snd_soc_codec *codec)