Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2d9de54 authored by Jarkko Nikula's avatar Jarkko Nikula Committed by Mark Brown
Browse files

ASoC: dapm: Fix NULL pointer dereference when registering card with widgets



Commit 0bd2ac3d ("ASoC: Remove CODEC pointer from snd_soc_dapm_context")
introduced regression to snd_soc_dapm_new_controls() when registering a card
with card->dapm_widgets set. Call chain is:

    snd_soc_register_card()
    -> snd_soc_instantiate_card()
       -> snd_soc_dapm_new_controls()
          -> snd_soc_dapm_new_control()

Null pointer dereference occurs since card->dapm context doesn't have
associated component. Fix this by setting widget codec pointer
conditionally.

Signed-off-by: default avatarJarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0bd2ac3d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3107,6 +3107,7 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
	}

	w->dapm = dapm;
	if (dapm->component)
		w->codec = dapm->component->codec;
	INIT_LIST_HEAD(&w->sources);
	INIT_LIST_HEAD(&w->sinks);