From: Takashi Iwai Date: Fri, 3 Jul 2009 21:10:23 +0000 (+0200) Subject: ALSA: hda - Add sanity check in PCM open callback X-Git-Tag: accepted/tizen/common/20141203.182822~14893^2~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c470331e69bd54d11a9ea3c27a0e4ad783d02d6b;p=platform%2Fkernel%2Flinux-arm64.git 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 --- diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index b36dc46..1877d95 100644 --- a/sound/pci/hda/hda_intel.c +++ b/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); 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; }