Skip to contentSkip to conversation

hw/arm_timer.c: Fix bounds check for Integrator timer accesses

PATCH Applied Peter Maydell 2 participants 2 messages Nov 11, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm_timer.c: Fix bounds check for Integrator timer accesses

There are only three counter/timers on the integrator board:
correct the bounds check to avoid an array overrun. (Spotted by Coverity, see bug 887883).

---
 hw/arm_timer.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/arm_timer.c +2 -2
index 09a4b24..66db81d 100644
@@ -269,7 +269,7 @@ static uint64_t icp_pit_read(void *opaque, target_phys_addr_t offset,
 
     /* ??? Don't know the PrimeCell ID for this device.  */
     n = offset >> 8;
-    if (n > 3) {
+    if (n > 2) {
         hw_error("sp804_read: Bad timer %d\n", n);
     }
 
@@ -283,7 +283,7 @@ static void icp_pit_write(void *opaque, target_phys_addr_t offset,
     int n;
 
     n = offset >> 8;
-    if (n > 3) {
+    if (n > 2) {
         hw_error("sp804_write: Bad timer %d\n", n);
     }
 
Signature · 1 line
1.7.1
#1 lore raw
Quoted 5 lines · Peter Maydell

There are only three counter/timers on the integrator board:
correct the bounds check to avoid an array overrun. (Spotted by Coverity, see bug 887883).

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 26 lines
---
  hw/arm_timer.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
hw/arm_timer.c +2 -2
index 09a4b24..66db81d 100644
@@ -269,7 +269,7 @@ static uint64_t icp_pit_read(void *opaque, target_phys_addr_t offset,
 
      /* ??? Don't know the PrimeCell ID for this device.  */
      n = offset>>  8;
-    if (n>  3) {
+    if (n>  2) {
          hw_error("sp804_read: Bad timer %d\n", n);
      }
 
@@ -283,7 +283,7 @@ static void icp_pit_write(void *opaque, target_phys_addr_t offset,
      int n;
 
      n = offset>>  8;
-    if (n>  3) {
+    if (n>  2) {
          hw_error("sp804_write: Bad timer %d\n", n);
      }