Skip to content

Commit

Permalink
ASoC: dapm: avoid container_of() to get component
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
babnskidata authored and broonie committed Oct 8, 2024
1 parent 9814c14 commit 3fe9f58
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sound/soc/soc-dapm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2785,10 +2785,10 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_update_dai);

int snd_soc_dapm_widget_name_cmp(struct snd_soc_dapm_widget *widget, const char *s)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
struct snd_soc_component *component = widget->dapm->component;
const char *wname = widget->name;

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

return strcmp(wname, s);
Expand Down

0 comments on commit 3fe9f58

Please sign in to comment.