Skip to content

Commit

Permalink
ASoC: dapm: release lock on error paths
Browse files Browse the repository at this point in the history
We added locking here but there were a couple error paths where we
forgot to drop the lock before returning.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Dan Carpenter authored and Mark Brown committed Apr 15, 2012
1 parent 7203a62 commit 60884c2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions sound/soc/soc-dapm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2131,21 +2131,21 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
const struct snd_soc_dapm_route *route, int num)
{
int i, ret;
int i, ret = 0;

mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT);
for (i = 0; i < num; i++) {
ret = snd_soc_dapm_add_route(dapm, route);
if (ret < 0) {
dev_err(dapm->dev, "Failed to add route %s->%s\n",
route->source, route->sink);
return ret;
break;
}
route++;
}
mutex_unlock(&dapm->card->dapm_mutex);

return 0;
return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes);

Expand Down Expand Up @@ -2849,6 +2849,7 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
{
struct snd_soc_dapm_widget *w;
int i;
int ret = 0;

mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT);
for (i = 0; i < num; i++) {
Expand All @@ -2857,12 +2858,13 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
dev_err(dapm->dev,
"ASoC: Failed to create DAPM control %s\n",
widget->name);
return -ENOMEM;
ret = -ENOMEM;
break;
}
widget++;
}
mutex_unlock(&dapm->card->dapm_mutex);
return 0;
return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls);

Expand Down

0 comments on commit 60884c2

Please sign in to comment.