Skip to content

Commit 84f9df1

Browse files
cladischtiwai
authored andcommitted
ALSA: ymfpci: fix PCM open error handling
The installation of the minimum period size constraint in the PCM open callbacks was not checked for errors. Add this check, and move the call to the beginning of the function to avoid having to do any cleanups in the error case. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 14515a0 commit 84f9df1

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

‎sound/pci/ymfpci/ymfpci_main.c‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,18 +897,24 @@ static int snd_ymfpci_playback_open_1(struct snd_pcm_substream *substream)
897897
struct snd_ymfpci *chip = snd_pcm_substream_chip(substream);
898898
struct snd_pcm_runtime *runtime = substream->runtime;
899899
struct snd_ymfpci_pcm *ypcm;
900+
int err;
901+
902+
runtime->hw = snd_ymfpci_playback;
903+
/* FIXME? True value is 256/48 = 5.33333 ms */
904+
err = snd_pcm_hw_constraint_minmax(runtime,
905+
SNDRV_PCM_HW_PARAM_PERIOD_TIME,
906+
5334, UINT_MAX);
907+
if (err < 0)
908+
return err;
900909

901910
ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL);
902911
if (ypcm == NULL)
903912
return -ENOMEM;
904913
ypcm->chip = chip;
905914
ypcm->type = PLAYBACK_VOICE;
906915
ypcm->substream = substream;
907-
runtime->hw = snd_ymfpci_playback;
908916
runtime->private_data = ypcm;
909917
runtime->private_free = snd_ymfpci_pcm_free_substream;
910-
/* FIXME? True value is 256/48 = 5.33333 ms */
911-
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 5333, UINT_MAX);
912918
return 0;
913919
}
914920

@@ -1013,6 +1019,15 @@ static int snd_ymfpci_capture_open(struct snd_pcm_substream *substream,
10131019
struct snd_ymfpci *chip = snd_pcm_substream_chip(substream);
10141020
struct snd_pcm_runtime *runtime = substream->runtime;
10151021
struct snd_ymfpci_pcm *ypcm;
1022+
int err;
1023+
1024+
runtime->hw = snd_ymfpci_capture;
1025+
/* FIXME? True value is 256/48 = 5.33333 ms */
1026+
err = snd_pcm_hw_constraint_minmax(runtime,
1027+
SNDRV_PCM_HW_PARAM_PERIOD_TIME,
1028+
5334, UINT_MAX);
1029+
if (err < 0)
1030+
return err;
10161031

10171032
ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL);
10181033
if (ypcm == NULL)
@@ -1022,9 +1037,6 @@ static int snd_ymfpci_capture_open(struct snd_pcm_substream *substream,
10221037
ypcm->substream = substream;
10231038
ypcm->capture_bank_number = capture_bank_number;
10241039
chip->capture_substream[capture_bank_number] = substream;
1025-
runtime->hw = snd_ymfpci_capture;
1026-
/* FIXME? True value is 256/48 = 5.33333 ms */
1027-
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 5333, UINT_MAX);
10281040
runtime->private_data = ypcm;
10291041
runtime->private_free = snd_ymfpci_pcm_free_substream;
10301042
snd_ymfpci_hw_start(chip);

0 commit comments

Comments
 (0)