瀏覽代碼

ALSA: hda - Add sanity check in PCM open callback

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>
Takashi Iwai 16 年之前
父節點
當前提交
c470331e69
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      sound/pci/hda/hda_intel.c

+ 6 - 0
sound/pci/hda/hda_intel.c

@@ -1464,6 +1464,12 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
 	snd_pcm_set_sync(substream);
 	snd_pcm_set_sync(substream);
 	mutex_unlock(&chip->open_mutex);
 	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;
 	return 0;
 }
 }