Skip to content

Commit 3fe9f58

Browse files
babnskidatabroonie
authored andcommitted
ASoC: dapm: avoid container_of() to get component
The current implementation does not work for widgets of DAPMs without component, as snd_soc_dapm_to_component() requires it. If the widget is directly owned by the card, e.g. as it is the case for the tegra implementation, the call leads to UB. Therefore directly access the component of the widget's DAPM to be able to check if a component is available. Fixes: f82eb06 ("ASoC: tegra: machine: Handle component name prefix") Cc: [email protected] # v6.7+ Signed-off-by: Benjamin Bara <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 9814c14 commit 3fe9f58

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/soc/soc-dapm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,10 +2785,10 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_update_dai);
27852785

27862786
int snd_soc_dapm_widget_name_cmp(struct snd_soc_dapm_widget *widget, const char *s)
27872787
{
2788-
struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
2788+
struct snd_soc_component *component = widget->dapm->component;
27892789
const char *wname = widget->name;
27902790

2791-
if (component->name_prefix)
2791+
if (component && component->name_prefix)
27922792
wname += strlen(component->name_prefix) + 1; /* plus space */
27932793

27942794
return strcmp(wname, s);

0 commit comments

Comments
 (0)