1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-15 15:06:42 +00:00

Release lock for a while during chn_reset() / pcm_chnalloc() operation

while malloc()ing, this fixes LOR 129.

See
 - http://lists.freebsd.org/pipermail/freebsd-current/2005-June/051157.html
 - http://lists.freebsd.org/pipermail/freebsd-current/2005-August/054620.html
 - http://sources.zabbadoz.net/freebsd/lor.html#129

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
This commit is contained in:
Alexander Leidinger 2005-09-10 17:51:38 +00:00
parent 5cfcc28b60
commit a423446c40
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=149951

View File

@ -241,13 +241,13 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
*/
if (flags & FREAD) {
/* open for read */
pcm_unlock(d);
if (devtype == SND_DEV_DSPREC)
rdch = pcm_chnalloc(d, PCMDIR_REC, td->td_proc->p_pid, PCMCHAN(i_dev));
else
rdch = pcm_chnalloc(d, PCMDIR_REC, td->td_proc->p_pid, -1);
if (!rdch) {
/* no channel available, exit */
pcm_unlock(d);
splx(s);
return EBUSY;
}
@ -255,11 +255,11 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
if (chn_reset(rdch, fmt)) {
pcm_chnrelease(rdch);
i_dev->si_drv1 = NULL;
pcm_unlock(d);
splx(s);
return ENODEV;
}
pcm_lock(d);
if (flags & O_NONBLOCK)
rdch->flags |= CHN_F_NBIO;
pcm_chnref(rdch, 1);
@ -272,6 +272,7 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
if (flags & FWRITE) {
/* open for write */
pcm_unlock(d);
wrch = pcm_chnalloc(d, PCMDIR_PLAY, td->td_proc->p_pid, -1);
error = 0;
@ -280,6 +281,7 @@ dsp_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
else if (chn_reset(wrch, fmt))
error = ENODEV;
pcm_lock(d);
if (error != 0) {
if (wrch) {
/*
@ -950,6 +952,8 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, struct thread *
*arg_i = 24;
else if (chn->format & AFMT_32BIT)
*arg_i = 32;
else
ret = EINVAL;
CHN_UNLOCK(chn);
break;