Skip to content

Commit 7fcd9bb

Browse files
ranj063tiwai
authored andcommitted
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: Pierre-Louis Bossart <[email protected]> Signed-off-by: Ranjani Sridharan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent c2c3657 commit 7fcd9bb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sound/pci/hda/hda_codec.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2935,6 +2935,10 @@ static int hda_codec_runtime_suspend(struct device *dev)
29352935
struct hda_codec *codec = dev_to_hda_codec(dev);
29362936
unsigned int state;
29372937

2938+
/* Nothing to do if card registration fails and the component driver never probes */
2939+
if (!codec->card)
2940+
return 0;
2941+
29382942
cancel_delayed_work_sync(&codec->jackpoll_work);
29392943
state = hda_call_codec_suspend(codec);
29402944
if (codec->link_down_at_suspend ||
@@ -2949,6 +2953,10 @@ static int hda_codec_runtime_resume(struct device *dev)
29492953
{
29502954
struct hda_codec *codec = dev_to_hda_codec(dev);
29512955

2956+
/* Nothing to do if card registration fails and the component driver never probes */
2957+
if (!codec->card)
2958+
return 0;
2959+
29522960
codec_display_power(codec, true);
29532961
snd_hdac_codec_link_up(&codec->core);
29542962
hda_call_codec_resume(codec);

0 commit comments

Comments
 (0)