Commit c470331e69bd54d11a9ea3c27a0e4ad783d02d6b
1 parent
70d321e638
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 6 additions and 0 deletions Side-by-side Diff
sound/pci/hda/hda_intel.c
... | ... | @@ -1464,6 +1464,12 @@ |
1464 | 1464 | snd_pcm_set_sync(substream); |
1465 | 1465 | mutex_unlock(&chip->open_mutex); |
1466 | 1466 | |
1467 | + if (snd_BUG_ON(!runtime->hw.channels_min || !runtime->hw.channels_max)) | |
1468 | + return -EINVAL; | |
1469 | + if (snd_BUG_ON(!runtime->hw.formats)) | |
1470 | + return -EINVAL; | |
1471 | + if (snd_BUG_ON(!runtime->hw.rates)) | |
1472 | + return -EINVAL; | |
1467 | 1473 | return 0; |
1468 | 1474 | } |
1469 | 1475 |