summaryrefslogtreecommitdiff
path: root/src/drivers/ao_bufio.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-03-28 15:55:35 -0700
committerKeith Packard <keithp@keithp.com>2013-03-28 15:55:35 -0700
commitd1fe0654b45cc8f944394308cf29945b537becc4 (patch)
treec6cbfd93693c62f7844778585d7f5c652e31453c /src/drivers/ao_bufio.c
parent6fe32e0fc407522101e805cf2653253cb3cee291 (diff)
altos: Add sanity checking to busy counts in bufio driver
Make sure the busy counts don't underflow or overflow. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/drivers/ao_bufio.c')
-rw-r--r--src/drivers/ao_bufio.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/drivers/ao_bufio.c b/src/drivers/ao_bufio.c
index 9a5e801b..10b32ceb 100644
--- a/src/drivers/ao_bufio.c
+++ b/src/drivers/ao_bufio.c
@@ -205,10 +205,13 @@ ao_bufio_get(uint32_t block)
bufio->block = 0xffffffff;
bufio = NULL;
}
- }
+ } else
+ ao_panic(AO_PANIC_BUFIO);
}
if (bufio) {
bufio->busy++;
+ if (!bufio->busy)
+ ao_panic(AO_PANIC_BUFIO);
buf = ao_bufio_to_buf(bufio);
}
ao_bufio_unlock();
@@ -227,6 +230,9 @@ ao_bufio_put(uint8_t *buf, uint8_t write)
ao_bufio_lock();
bufio = ao_buf_to_bufio(buf);
+ if (!bufio->busy)
+ ao_panic(AO_PANIC_BUFIO);
+
DBG ("idle buffer %d write %d\n", ao_bufio_to_num(bufio), write);
bufio->dirty |= write;
if (!--bufio->busy) {