ALSA: hda: fix NULL pointer dereference during suspend
[sfrench/cifs-2.6.git] / sound / pci / hda / hda_codec.c
index 7e3ae4534df9164cb57d69a19f29f006ad3a218c..803978d69e3c4d283bfbe1b63512296bfcf43402 100644 (file)
@@ -2935,6 +2935,10 @@ static int hda_codec_runtime_suspend(struct device *dev)
        struct hda_codec *codec = dev_to_hda_codec(dev);
        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);
        state = hda_call_codec_suspend(codec);
        if (codec->link_down_at_suspend ||
@@ -2949,6 +2953,10 @@ static int hda_codec_runtime_resume(struct device *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);
        snd_hdac_codec_link_up(&codec->core);
        hda_call_codec_resume(codec);