Patchwork [RFC,3/5] pc: Don't crash on apic_accept_pic_intr() if CPU has no apic_state

login
register
mail settings
Submitter Eduardo Habkost
Date April 30, 2014, 8:29 p.m.
Message ID <1398889773-14652-4-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/344318/
State New
Headers show

Comments

Eduardo Habkost - April 30, 2014, 8:29 p.m.
apic_accept_pic_intr() returns -1 if gets NULL as argument. So, instead
of checking if apic_accept_pic_intr() returns non-zero, check for return
value > 0.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/i386/pc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 14f0d91..c747615 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -197,7 +197,7 @@  static void pic_irq_request(void *opaque, int irq, int level)
     if (cpu->apic_state) {
         CPU_FOREACH(cs) {
             cpu = X86_CPU(cs);
-            if (apic_accept_pic_intr(cpu->apic_state)) {
+            if (apic_accept_pic_intr(cpu->apic_state) > 0) {
                 apic_deliver_pic_intr(cpu->apic_state, level);
             }
         }