summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2019-04-03 07:44:53 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2019-04-03 07:44:53 +0000
commitaa13007e985469bc95b740af7467c956c1cac361 (patch)
tree9427d7db535ce76d9758fd39b774da53cc7f50fc /sys/dev/usb
parent55be05d2212293879bbb42631e92f46f45b44c3f (diff)
Check for available space before copying data to the bounce buffers.
No behavior change as we don't call uaudio_pdata_copy() in situations when bounce buffers may not be available.
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/uaudio.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c
index bbfe24022e3..f8284c0aa54 100644
--- a/sys/dev/usb/uaudio.c
+++ b/sys/dev/usb/uaudio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uaudio.c,v 1.136 2019/04/03 07:38:12 ratchov Exp $ */
+/* $OpenBSD: uaudio.c,v 1.137 2019/04/03 07:44:52 ratchov Exp $ */
/*
* Copyright (c) 2018 Alexandre Ratchov <alex@caoua.org>
*
@@ -3036,11 +3036,11 @@ uaudio_pdata_copy(struct uaudio_softc *sc)
getmicrotime(&tv);
#endif
- index = s->data_nextxfer + s->ubuf_xfer;
- if (index >= s->nxfers)
- index -= s->nxfers;
- xfer = s->data_xfers + index;
- while (sc->copy_todo > 0) {
+ while (sc->copy_todo > 0 && s->ubuf_xfer < s->nxfers) {
+ index = s->data_nextxfer + s->ubuf_xfer;
+ if (index >= s->nxfers)
+ index -= s->nxfers;
+ xfer = s->data_xfers + index;
avail = s->ring_end - s->ring_pos;
count = xfer->size - s->ubuf_pos;
if (count > avail)
@@ -3072,12 +3072,6 @@ uaudio_pdata_copy(struct uaudio_softc *sc)
}
#endif
s->ubuf_xfer++;
- if (s->ubuf_xfer == s->nxfers)
- break;
- index = s->data_nextxfer + s->ubuf_xfer;
- if (index >= s->nxfers)
- index -= s->nxfers;
- xfer = s->data_xfers + index;
}
}
}