Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142740353
D53666.id166290.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D53666.id166290.diff
View Options
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -438,7 +438,7 @@
{
struct snd_dbuf *bs = c->bufsoft;
void *off;
- int ret, timeout, sz, t, p;
+ int ret, timeout, sz, p;
CHN_LOCKASSERT(c);
@@ -446,24 +446,17 @@
timeout = chn_timeout * hz;
while (ret == 0 && buf->uio_resid > 0) {
+ p = sndbuf_getfreeptr(bs);
sz = min(buf->uio_resid, sndbuf_getfree(bs));
+ sz = min(sz, bs->bufsize - p);
if (sz > 0) {
- /*
- * The following assumes that the free space in
- * the buffer can never be less around the
- * unlock-uiomove-lock sequence.
- */
- while (ret == 0 && sz > 0) {
- p = sndbuf_getfreeptr(bs);
- t = min(sz, bs->bufsize - p);
- off = sndbuf_getbufofs(bs, p);
- CHN_UNLOCK(c);
- ret = uiomove(off, t, buf);
- CHN_LOCK(c);
- sz -= t;
- sndbuf_acquire(bs, NULL, t);
- }
- ret = 0;
+ off = sndbuf_getbufofs(bs, p);
+ sndbuf_acquire(bs, NULL, sz);
+ CHN_UNLOCK(c);
+ ret = uiomove(off, sz, buf);
+ CHN_LOCK(c);
+ if (ret != 0)
+ break;
if (CHN_STOPPED(c) && !(c->flags & CHN_F_NOTRIGGER)) {
ret = chn_start(c, 0);
if (ret != 0)
@@ -483,13 +476,7 @@
ret = EAGAIN;
} else {
ret = chn_sleep(c, timeout);
- if (ret == EAGAIN) {
- ret = EINVAL;
- c->flags |= CHN_F_DEAD;
- device_printf(c->dev, "%s(): %s: "
- "play interrupt timeout, channel dead\n",
- __func__, c->name);
- } else if (ret == ERESTART || ret == EINTR)
+ if (ret == ERESTART || ret == EINTR)
c->flags |= CHN_F_ABORTING;
}
}
@@ -552,7 +539,7 @@
{
struct snd_dbuf *bs = c->bufsoft;
void *off;
- int ret, timeout, sz, t, p;
+ int ret, timeout, sz, p;
CHN_LOCKASSERT(c);
@@ -568,35 +555,22 @@
timeout = chn_timeout * hz;
while (ret == 0 && buf->uio_resid > 0) {
+ p = sndbuf_getreadyptr(bs);
sz = min(buf->uio_resid, sndbuf_getready(bs));
+ sz = min(sz, bs->bufsize - p);
if (sz > 0) {
- /*
- * The following assumes that the free space in
- * the buffer can never be less around the
- * unlock-uiomove-lock sequence.
- */
- while (ret == 0 && sz > 0) {
- p = sndbuf_getreadyptr(bs);
- t = min(sz, bs->bufsize - p);
- off = sndbuf_getbufofs(bs, p);
- CHN_UNLOCK(c);
- ret = uiomove(off, t, buf);
- CHN_LOCK(c);
- sz -= t;
- sndbuf_dispose(bs, NULL, t);
- }
- ret = 0;
+ off = sndbuf_getbufofs(bs, p);
+ sndbuf_dispose(bs, NULL, sz);
+ CHN_UNLOCK(c);
+ ret = uiomove(off, sz, buf);
+ CHN_LOCK(c);
+ if (ret != 0)
+ break;
} else if (c->flags & (CHN_F_NBIO | CHN_F_NOTRIGGER))
ret = EAGAIN;
else {
ret = chn_sleep(c, timeout);
- if (ret == EAGAIN) {
- ret = EINVAL;
- c->flags |= CHN_F_DEAD;
- device_printf(c->dev, "%s(): %s: "
- "record interrupt timeout, channel dead\n",
- __func__, c->name);
- } else if (ret == ERESTART || ret == EINTR)
+ if (ret == ERESTART || ret == EINTR)
c->flags |= CHN_F_ABORTING;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 23, 11:08 PM (19 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25256930
Default Alt Text
D53666.id166290.diff (2 KB)
Attached To
Mode
D53666: sound: Fix KASSERT panics in chn_read() and chn_write()
Attached
Detach File
Event Timeline
Log In to Comment