aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen-Yu Tsai <wens@csie.org>2016-10-31 02:42:09 -0400
committerMark Brown <broonie@kernel.org>2016-10-31 11:46:16 -0400
commit85915b63ad8b796848f431b66c9ba5e356e722e5 (patch)
treef8c715b6380717ae4a7abda0ca4ed852650802ca
parent1001354ca34179f3db924eb66672442a173147dc (diff)
ASoC: sun4i-codec: return error code instead of NULL when create_card fails
When sun4i_codec_create_card fails, we do not assign a proper error code to the return value. The return value would be 0 from the previous function call, or we would have bailed out sooner. This would confuse the driver core into thinking the device probe succeeded, when in fact it didn't, leaving various devres based resources lingering. Make the create_card function pass back a meaningful error code, and assign it to the return value. Fixes: 45fb6b6f2aa3 ("ASoC: sunxi: add support for the on-chip codec on early Allwinner SoCs") Signed-off-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/sunxi/sun4i-codec.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index e047ec06d538..a60707761abf 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -765,11 +765,11 @@ static struct snd_soc_card *sun4i_codec_create_card(struct device *dev)
765 765
766 card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); 766 card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
767 if (!card) 767 if (!card)
768 return NULL; 768 return ERR_PTR(-ENOMEM);
769 769
770 card->dai_link = sun4i_codec_create_link(dev, &card->num_links); 770 card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
771 if (!card->dai_link) 771 if (!card->dai_link)
772 return NULL; 772 return ERR_PTR(-ENOMEM);
773 773
774 card->dev = dev; 774 card->dev = dev;
775 card->name = "sun4i-codec"; 775 card->name = "sun4i-codec";
@@ -876,7 +876,8 @@ static int sun4i_codec_probe(struct platform_device *pdev)
876 } 876 }
877 877
878 card = sun4i_codec_create_card(&pdev->dev); 878 card = sun4i_codec_create_card(&pdev->dev);
879 if (!card) { 879 if (IS_ERR(card)) {
880 ret = PTR_ERR(card);
880 dev_err(&pdev->dev, "Failed to create our card\n"); 881 dev_err(&pdev->dev, "Failed to create our card\n");
881 goto err_unregister_codec; 882 goto err_unregister_codec;
882 } 883 }