Skip to contentSkip to conversation

misc: zynq-xadc: Fix off-by-one

PATCH Applied Peter Crosthwaite 2 participants 2 messages Jan 18, 2016 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc: zynq-xadc: Fix off-by-one

This bounds check was off-by-one. Fix.

---
 hw/misc/zynq-xadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/zynq-xadc.c +1 -1
index 1a32595..d160ff2 100644
@@ -220,7 +220,7 @@ static void zynq_xadc_write(void *opaque, hwaddr offset, uint64_t val,
             break;
         }
 
-        if (xadc_reg > ZYNQ_XADC_NUM_ADC_REGS && xadc_cmd != CMD_NOP) {
+        if (xadc_reg >= ZYNQ_XADC_NUM_ADC_REGS && xadc_cmd != CMD_NOP) {
             qemu_log_mask(LOG_GUEST_ERROR, "read/write op to invalid xadc "
                           "reg 0x%x\n", xadc_reg);
             break;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 22 lines · Peter Crosthwaite

This bounds check was off-by-one. Fix.

---
 hw/misc/zynq-xadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/zynq-xadc.c +1 -2
index 1a32595..d160ff2 100644
@@ -220,7 +220,7 @@ static void zynq_xadc_write(void *opaque, hwaddr offset, uint64_t val,
             break;
         }
 
-        if (xadc_reg > ZYNQ_XADC_NUM_ADC_REGS && xadc_cmd != CMD_NOP) {
+        if (xadc_reg >= ZYNQ_XADC_NUM_ADC_REGS && xadc_cmd != CMD_NOP) {
             qemu_log_mask(LOG_GUEST_ERROR, "read/write op to invalid xadc "
                           "reg 0x%x\n", xadc_reg);
             break;
--
Quoted 1 line

1.9.1

Applied to target-arm.next, thanks.

-- PMM