Move lock in pcm_chn_add() to after malloc.

PR:             kern/40157
Submitted by:   Dan Lukes <dan@obluda.cz>
This commit is contained in:
Orion Hodson 2002-07-22 02:38:20 +00:00
parent 0cd59a38ce
commit 7cf0e77a00
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=100478

View File

@ -428,14 +428,13 @@ pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch, int mkdev)
struct snddev_channel *sce, *tmp, *after;
int unit = device_get_unit(d->dev);
snd_mtxlock(d->lock);
sce = malloc(sizeof(*sce), M_DEVBUF, M_WAITOK | M_ZERO);
if (!sce) {
snd_mtxunlock(d->lock);
return ENOMEM;
}
snd_mtxlock(d->lock);
sce->channel = ch;
if (SLIST_EMPTY(&d->channels)) {
SLIST_INSERT_HEAD(&d->channels, sce, link);