Skip to content

Commit

Permalink
ASoC: Fix snd_soc_register_dais error handling
Browse files Browse the repository at this point in the history
kzalloc for dai may fail at any iteration of the for loop,
thus properly unregister already registered DAIs before return error.

The error handling code in snd_soc_register_dais() already ensure all the DAIs
are unregistered before return error, we can remove the error handling code
to unregister DAIs in snd_soc_register_codec().

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Nov 3, 2010
1 parent 29c798f commit c46e007
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3043,8 +3043,10 @@ int snd_soc_register_dais(struct device *dev,
for (i = 0; i < count; i++) {

dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL);
if (dai == NULL)
return -ENOMEM;
if (dai == NULL) {
ret = -ENOMEM;
goto err;
}

/* create DAI component name */
dai->name = fmt_multiple_name(dev, &dai_drv[i]);
Expand Down Expand Up @@ -3263,9 +3265,6 @@ int snd_soc_register_codec(struct device *dev,
return 0;

error:
for (i--; i >= 0; i--)
snd_soc_unregister_dai(dev);

if (codec->reg_cache)
kfree(codec->reg_cache);
kfree(codec->name);
Expand Down

0 comments on commit c46e007

Please sign in to comment.