Skip to content

Commit 01fdcb8

Browse files
ranj063gregkh
authored andcommitted
ALSA: hda: fix NULL pointer dereference during suspend
[ Upstream commit 7fcd9bb ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent eb96e4f commit 01fdcb8

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
@@ -2924,6 +2924,10 @@ static int hda_codec_runtime_suspend(struct device *dev)
29242924
struct hda_codec *codec = dev_to_hda_codec(dev);
29252925
unsigned int state;
29262926

2927+
/* Nothing to do if card registration fails and the component driver never probes */
2928+
if (!codec->card)
2929+
return 0;
2930+
29272931
cancel_delayed_work_sync(&codec->jackpoll_work);
29282932
state = hda_call_codec_suspend(codec);
29292933
if (codec->link_down_at_suspend ||
@@ -2938,6 +2942,10 @@ static int hda_codec_runtime_resume(struct device *dev)
29382942
{
29392943
struct hda_codec *codec = dev_to_hda_codec(dev);
29402944

2945+
/* Nothing to do if card registration fails and the component driver never probes */
2946+
if (!codec->card)
2947+
return 0;
2948+
29412949
codec_display_power(codec, true);
29422950
snd_hdac_codec_link_up(&codec->core);
29432951
hda_call_codec_resume(codec);

0 commit comments

Comments
 (0)