Commit aba66536 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Fix error path in the sanity check in azx_pcm_open()

Release resources cleanly after errors in the sanity check in
azx_pcm_open().
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 02358fcf
...@@ -1455,6 +1455,17 @@ static int azx_pcm_open(struct snd_pcm_substream *substream) ...@@ -1455,6 +1455,17 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
return err; return err;
} }
snd_pcm_limit_hw_rates(runtime); snd_pcm_limit_hw_rates(runtime);
/* sanity check */
if (snd_BUG_ON(!runtime->hw.channels_min) ||
snd_BUG_ON(!runtime->hw.channels_max) ||
snd_BUG_ON(!runtime->hw.formats) ||
snd_BUG_ON(!runtime->hw.rates)) {
azx_release_device(azx_dev);
hinfo->ops.close(hinfo, apcm->codec, substream);
snd_hda_power_down(apcm->codec);
mutex_unlock(&chip->open_mutex);
return -EINVAL;
}
spin_lock_irqsave(&chip->reg_lock, flags); spin_lock_irqsave(&chip->reg_lock, flags);
azx_dev->substream = substream; azx_dev->substream = substream;
azx_dev->running = 0; azx_dev->running = 0;
...@@ -1463,13 +1474,6 @@ static int azx_pcm_open(struct snd_pcm_substream *substream) ...@@ -1463,13 +1474,6 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
runtime->private_data = azx_dev; runtime->private_data = azx_dev;
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;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment