[Qemu-devel] [PATCH] ioapic: remove useless lower bounds check

Paolo Bonzini posted 1 patch 7 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180704120412.19020-2-pbonzini@redhat.com
Test checkpatch passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
Test s390x passed
hw/intc/ioapic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH] ioapic: remove useless lower bounds check
Posted by Paolo Bonzini 7 years, 4 months ago
The vector cannot be negative.  Coverity now reports this because it sees an
array access before the check, in ioapic_stat_update_irq.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/intc/ioapic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c
index b3937807c2..b6896ac4ce 100644
--- a/hw/intc/ioapic.c
+++ b/hw/intc/ioapic.c
@@ -152,7 +152,7 @@ static void ioapic_set_irq(void *opaque, int vector, int level)
     if (vector == 0) {
         vector = 2;
     }
-    if (vector >= 0 && vector < IOAPIC_NUM_PINS) {
+    if (vector < IOAPIC_NUM_PINS) {
         uint32_t mask = 1 << vector;
         uint64_t entry = s->ioredtbl[vector];
 
-- 
2.17.1


Re: [Qemu-devel] [PATCH] ioapic: remove useless lower bounds check
Posted by Peter Xu 7 years, 4 months ago
On Wed, Jul 04, 2018 at 02:04:12PM +0200, Paolo Bonzini wrote:
> The vector cannot be negative.  Coverity now reports this because it sees an
> array access before the check, in ioapic_stat_update_irq.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Peter Xu <peterx@redhat.com>

Thanks!

-- 
Peter Xu