[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/29] device/blkio.c (block_io): check if io_count is larger or
From: |
Marin Ramesa |
Subject: |
[PATCH 05/29] device/blkio.c (block_io): check if io_count is larger or equal to zero |
Date: |
Mon, 9 Dec 2013 23:57:20 +0100 |
Check if member io_count is non-negative. If it's negative, the call to
device_read_alloc() will fail. Return KERN_INVALID_ARGUMENT in that case.
* device/blkio.c (block_io): Check if member io_count is non-negative.
---
device/blkio.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/device/blkio.c b/device/blkio.c
index 939067d..c989157 100644
--- a/device/blkio.c
+++ b/device/blkio.c
@@ -57,8 +57,12 @@ io_return_t block_io(strat, max_count, ior)
* If reading, allocate memory. If writing, wire
* down the incoming memory.
*/
- if (ior->io_op & IO_READ)
- rc = device_read_alloc(ior, (vm_size_t)ior->io_count);
+ if (ior->io_op & IO_READ) {
+ if (ior->io_count >= 0)
+ rc = device_read_alloc(ior, (vm_size_t)ior->io_count);
+ else
+ return KERN_INVALID_ARGUMENT;
+ }
else
rc = device_write_get(ior, &wait);
--
1.8.1.4
- [PATCH 01/29] i386: move prototypes to fix implicit declaration of function, Marin Ramesa, 2013/12/09
- [PATCH 03/29] i386/i386/db_interface.c: use vm_offset_t instead of an unsigned int, Marin Ramesa, 2013/12/09
- [PATCH 06/29] device/chario.c (char_write): check if io_count is larger or equal to zero and cast it to vm_size_t, Marin Ramesa, 2013/12/09
- [PATCH 07/29] device/chario.c (char_read): check if io_count is larger or equal to zero, Marin Ramesa, 2013/12/09
- [PATCH 08/29] device/chario.c: trivial stylistic fix for consistency, Marin Ramesa, 2013/12/09
- [PATCH 09/29] device/cirbuf.c (getc): use char instead of an unsigned char, Marin Ramesa, 2013/12/09