diff mbox

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

Message ID 1453101737-11255-1-git-send-email-crosthwaite.peter@gmail.com
State New
Headers show

Commit Message

Peter Crosthwaite Jan. 18, 2016, 7:22 a.m. UTC
This bounds check was off-by-one. Fix.

Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
 hw/misc/zynq-xadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Peter Maydell Jan. 18, 2016, 11:42 a.m. UTC | #1
On 18 January 2016 at 07:22, Peter Crosthwaite
<crosthwaitepeter@gmail.com> wrote:
> This bounds check was off-by-one. Fix.
>
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
> ---
>  hw/misc/zynq-xadc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/misc/zynq-xadc.c b/hw/misc/zynq-xadc.c
> index 1a32595..d160ff2 100644
> --- a/hw/misc/zynq-xadc.c
> +++ b/hw/misc/zynq-xadc.c
> @@ -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;
> --
> 1.9.1



Applied to target-arm.next, thanks.

-- PMM
diff mbox

Patch

diff --git a/hw/misc/zynq-xadc.c b/hw/misc/zynq-xadc.c
index 1a32595..d160ff2 100644
--- a/hw/misc/zynq-xadc.c
+++ b/hw/misc/zynq-xadc.c
@@ -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;