[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/29] device/chario.c (char_read): check if io_count is larger o
From: |
Marin Ramesa |
Subject: |
[PATCH 07/29] device/chario.c (char_read): check if io_count is larger or equal to zero |
Date: |
Mon, 9 Dec 2013 23:57:22 +0100 |
Check if member io_count is non-negative. If it is negative the call
to device_read_alloc() will fail. Return KERN_INVALID_ARGUMENT in that
case.
* device/chario.c (char_read): Check if member io_count is non-negative.
---
device/chario.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/device/chario.c b/device/chario.c
index c9f946c..f912924 100644
--- a/device/chario.c
+++ b/device/chario.c
@@ -394,7 +394,11 @@ io_return_t char_read(
/*
* Allocate memory for read buffer.
*/
- rc = device_read_alloc(ior, (vm_size_t)ior->io_count);
+ if (ior->io_count >= 0)
+ rc = device_read_alloc(ior, (vm_size_t)ior->io_count);
+ else
+ return KERN_INVALID_ARGUMENT;
+
if (rc != KERN_SUCCESS)
return rc;
--
1.8.1.4
- [PATCH 02/29] i386/i386at/kd_event.c (kbdsetstat): fix difference in signedness, (continued)
- [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 <=
- [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
- [PATCH 10/29] device/cirbuf.c (cb_alloc): use vm_size_t instead of an int, Marin Ramesa, 2013/12/09
- [PATCH 11/29] device/cirbuf.c (cb_free): use vm_size_t instead of an int, Marin Ramesa, 2013/12/09
- [PATCH 12/29] device/cons.c: fix argument list, Marin Ramesa, 2013/12/09
- [PATCH 13/29] device/dev_pager.c (device_pager_data_request): remove forward declaration, Marin Ramesa, 2013/12/09
- [PATCH 14/29] device/dev_pager.c (device_pager_data_request): cast to (void *) instead to (char *), Marin Ramesa, 2013/12/09
- [PATCH 15/29] device/dev_pager.c (device_pager_data_request_done): check if io_count is larger or equal to zero and cast it to vm_size_t, Marin Ramesa, 2013/12/09
- [PATCH 16/29] device/dev_pager.c (device_pager_data_request_done): check if io_residual is larger or equal to zero and cast it to size_t, Marin Ramesa, 2013/12/09