Skip to content

Commit 0fb250d

Browse files
benjamin-bara-skidatagregkh
authored andcommitted
ASoC: dapm: avoid container_of() to get component
commit 3fe9f58 upstream. 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: stable@vger.kernel.org # v6.7+ Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com> Link: https://patch.msgid.link/20241008-tegra-dapm-v2-1-5e999cb5f0e7@skidata.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ffde762 commit 0fb250d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

sound/soc/soc-dapm.c

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

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

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

27952795
return strcmp(wname, s);

0 commit comments

Comments
 (0)