Skip to content

Commit

Permalink
ASoC: dapm: Don't add prefix to widget stream name
Browse files Browse the repository at this point in the history
Commit fdb6eb0 ("ASoC: dapm: Modify widget stream name according to
prefix") fixed the case where a DAPM route between a DAI widget and a
DAC/ADC/AIF widget with a matching stream name was not created when the
DAPM context was using a prefix.

Unfortunately the patch introduced a few issues on its own like leaking the
dynamically allocated stream name memory and also not checking whether the
allocation succeeded in the first place.

It is also incomplete in that it still does not handle the case where
stream name of the widget is a substring of the stream name of the DAI,
which is explicitly allowed and works fine if no DAPM prefix is used.

Revert the commit and take a slightly different approach to solving the
issue. Instead of comparing the widget's stream name to the name of the DAI
widget compare it to the stream name of the DAI widget. The stream name of
the DAI widget is identical to the name of the DAI widget except that it
wont have the DAPM prefix added. So this approach behaves identical
regardless to whether the DAPM context uses a prefix or not.

We don't have to worry about potentially matching with a widget with the
same stream name, but from a different DAPM context with a different
prefix, since the code already makes sure that both the DAI widget and the
matched widget are from the same DAPM context.

Fixes: fdb6eb0 ("ASoC: dapm: Modify widget stream name according to prefix")
Signed-off-by: Lars-Peter Clausen <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
Cc: [email protected]
  • Loading branch information
larsclausen authored and broonie committed Jul 21, 2015
1 parent 2210438 commit a798c24
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions sound/soc/soc-dapm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3341,16 +3341,10 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm,
}

prefix = soc_dapm_prefix(dapm);
if (prefix) {
if (prefix)
w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name);
if (widget->sname)
w->sname = kasprintf(GFP_KERNEL, "%s %s", prefix,
widget->sname);
} else {
else
w->name = kasprintf(GFP_KERNEL, "%s", widget->name);
if (widget->sname)
w->sname = kasprintf(GFP_KERNEL, "%s", widget->sname);
}
if (w->name == NULL) {
kfree(w);
return NULL;
Expand Down Expand Up @@ -3799,7 +3793,7 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
break;
}

if (!w->sname || !strstr(w->sname, dai_w->name))
if (!w->sname || !strstr(w->sname, dai_w->sname))
continue;

if (dai_w->id == snd_soc_dapm_dai_in) {
Expand Down

0 comments on commit a798c24

Please sign in to comment.