diff options
author | Songjun Wu <songjun.wu@atmel.com> | 2015-12-11 06:07:37 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-12-13 01:57:00 +0300 |
commit | 32e69bad8ed9ed4e1bf1fd8217b61d5f87996253 (patch) | |
tree | 740c364030d2e8653d4726e05a8b35536b35782a /sound/soc | |
parent | 8005c49d9aea74d382f474ce11afbbc7d7130bec (diff) | |
download | linux-32e69bad8ed9ed4e1bf1fd8217b61d5f87996253.tar.xz |
ASoC: Atmel: ClassD: unregister codec when error occurs
Add code to unregister codec in probe function,
when the error occurs after the codec is registered.
Signed-off-by: Songjun Wu <songjun.wu@atmel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/atmel/atmel-classd.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index 8276675730ef..f3ffb39bfe27 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -636,8 +636,10 @@ static int atmel_classd_probe(struct platform_device *pdev) /* register sound card */ card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); - if (!card) - return -ENOMEM; + if (!card) { + ret = -ENOMEM; + goto unregister_codec; + } snd_soc_card_set_drvdata(card, dd); platform_set_drvdata(pdev, card); @@ -645,16 +647,20 @@ static int atmel_classd_probe(struct platform_device *pdev) ret = atmel_classd_asoc_card_init(dev, card); if (ret) { dev_err(dev, "failed to init sound card\n"); - return ret; + goto unregister_codec; } ret = devm_snd_soc_register_card(dev, card); if (ret) { dev_err(dev, "failed to register sound card: %d\n", ret); - return ret; + goto unregister_codec; } return 0; + +unregister_codec: + snd_soc_unregister_codec(dev); + return ret; } static int atmel_classd_remove(struct platform_device *pdev) |