ALSA: hda - Add sanity check in PCM open callback
authorTakashi Iwai <tiwai@suse.de>
Fri, 3 Jul 2009 21:10:23 +0000 (23:10 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 3 Jul 2009 21:10:23 +0000 (23:10 +0200)
Add some sanity checks of struct snd_pcm_hardware fields in the PCM
open callback of hda driver.  This makes a bit easier to debug any PCM
setup errors in the codec side.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_intel.c

index b36dc46615a4e1a801a89f60a8307216ae543220..1877d95d4aa6725807f4b77690dce7ab2f6c80d0 100644 (file)
@@ -1464,6 +1464,12 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
        snd_pcm_set_sync(substream);
        mutex_unlock(&chip->open_mutex);
 
+       if (snd_BUG_ON(!runtime->hw.channels_min || !runtime->hw.channels_max))
+               return -EINVAL;
+       if (snd_BUG_ON(!runtime->hw.formats))
+               return -EINVAL;
+       if (snd_BUG_ON(!runtime->hw.rates))
+               return -EINVAL;
        return 0;
 }