aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-07-05 05:44:46 -0400
committerTakashi Iwai <tiwai@suse.de>2009-07-05 05:44:46 -0400
commitaba6653617754e12763a0d3c9dda332b66190a50 (patch)
tree7facb76ceb0c3e2a01daaeb13bac3f145ac9eb9c
parent02358fcfa54ce018a0bb56ca9f5a898de574a9d3 (diff)
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: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/hda/hda_intel.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 1877d95d4aa6..16e09d740572 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1455,6 +1455,17 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1455 return err; 1455 return err;
1456 } 1456 }
1457 snd_pcm_limit_hw_rates(runtime); 1457 snd_pcm_limit_hw_rates(runtime);
1458 /* sanity check */
1459 if (snd_BUG_ON(!runtime->hw.channels_min) ||
1460 snd_BUG_ON(!runtime->hw.channels_max) ||
1461 snd_BUG_ON(!runtime->hw.formats) ||
1462 snd_BUG_ON(!runtime->hw.rates)) {
1463 azx_release_device(azx_dev);
1464 hinfo->ops.close(hinfo, apcm->codec, substream);
1465 snd_hda_power_down(apcm->codec);
1466 mutex_unlock(&chip->open_mutex);
1467 return -EINVAL;
1468 }
1458 spin_lock_irqsave(&chip->reg_lock, flags); 1469 spin_lock_irqsave(&chip->reg_lock, flags);
1459 azx_dev->substream = substream; 1470 azx_dev->substream = substream;
1460 azx_dev->running = 0; 1471 azx_dev->running = 0;
@@ -1463,13 +1474,6 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1463 runtime->private_data = azx_dev; 1474 runtime->private_data = azx_dev;
1464 snd_pcm_set_sync(substream); 1475 snd_pcm_set_sync(substream);
1465 mutex_unlock(&chip->open_mutex); 1476 mutex_unlock(&chip->open_mutex);
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;
1473 return 0; 1477 return 0;
1474} 1478}
1475 1479