Commit 7fcd9bb5 authored by Ranjani Sridharan's avatar Ranjani Sridharan Committed by Takashi Iwai

ALSA: hda: fix NULL pointer dereference during suspend

When the ASoC card registration fails and the codec component driver
never probes, the codec device is not initialized and therefore
memory for codec->wcaps is not allocated. This results in a NULL pointer
dereference when the codec driver suspend callback is invoked during
system suspend. Fix this by returning without performing any actions
during codec suspend/resume if the card was not registered successfully.
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20200728231011.1454066-1-ranjani.sridharan@linux.intel.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c2c3657f
...@@ -2935,6 +2935,10 @@ static int hda_codec_runtime_suspend(struct device *dev) ...@@ -2935,6 +2935,10 @@ static int hda_codec_runtime_suspend(struct device *dev)
struct hda_codec *codec = dev_to_hda_codec(dev); struct hda_codec *codec = dev_to_hda_codec(dev);
unsigned int state; unsigned int state;
/* Nothing to do if card registration fails and the component driver never probes */
if (!codec->card)
return 0;
cancel_delayed_work_sync(&codec->jackpoll_work); cancel_delayed_work_sync(&codec->jackpoll_work);
state = hda_call_codec_suspend(codec); state = hda_call_codec_suspend(codec);
if (codec->link_down_at_suspend || if (codec->link_down_at_suspend ||
...@@ -2949,6 +2953,10 @@ static int hda_codec_runtime_resume(struct device *dev) ...@@ -2949,6 +2953,10 @@ static int hda_codec_runtime_resume(struct device *dev)
{ {
struct hda_codec *codec = dev_to_hda_codec(dev); struct hda_codec *codec = dev_to_hda_codec(dev);
/* Nothing to do if card registration fails and the component driver never probes */
if (!codec->card)
return 0;
codec_display_power(codec, true); codec_display_power(codec, true);
snd_hdac_codec_link_up(&codec->core); snd_hdac_codec_link_up(&codec->core);
hda_call_codec_resume(codec); hda_call_codec_resume(codec);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment