Commit 1cdf9677 authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

KVM: ia64: Fix irq disabling leak in error handling code

(cherry picked from commit cab7a1ee)

There is a call to local_irq_restore in the normal exit case, so it would
seem that there should be one on an error return as well.

The semantic patch that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
expression l;
expression E,E1,E2;
@@

local_irq_save(l);
... when != local_irq_restore(l)
    when != spin_unlock_irqrestore(E,l)
    when any
    when strict
(
if (...) { ... when != local_irq_restore(l)
               when != spin_unlock_irqrestore(E1,l)
+   local_irq_restore(l);
    return ...;
}
|
if (...)
+   {local_irq_restore(l);
    return ...;
+   }
|
spin_unlock_irqrestore(E2,l);
|
local_irq_restore(l);
)
// </smpl>
Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7827feb4
...@@ -125,9 +125,9 @@ void kvm_arch_hardware_enable(void *garbage) ...@@ -125,9 +125,9 @@ void kvm_arch_hardware_enable(void *garbage)
PAGE_KERNEL)); PAGE_KERNEL));
local_irq_save(saved_psr); local_irq_save(saved_psr);
slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT); slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
local_irq_restore(saved_psr);
if (slot < 0) if (slot < 0)
return; return;
local_irq_restore(saved_psr);
spin_lock(&vp_lock); spin_lock(&vp_lock);
status = ia64_pal_vp_init_env(kvm_vsa_base ? status = ia64_pal_vp_init_env(kvm_vsa_base ?
...@@ -160,9 +160,9 @@ void kvm_arch_hardware_disable(void *garbage) ...@@ -160,9 +160,9 @@ void kvm_arch_hardware_disable(void *garbage)
local_irq_save(saved_psr); local_irq_save(saved_psr);
slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT); slot = ia64_itr_entry(0x3, KVM_VMM_BASE, pte, KVM_VMM_SHIFT);
local_irq_restore(saved_psr);
if (slot < 0) if (slot < 0)
return; return;
local_irq_restore(saved_psr);
status = ia64_pal_vp_exit_env(host_iva); status = ia64_pal_vp_exit_env(host_iva);
if (status) if (status)
...@@ -1258,6 +1258,7 @@ static int vti_vcpu_setup(struct kvm_vcpu *vcpu, int id) ...@@ -1258,6 +1258,7 @@ static int vti_vcpu_setup(struct kvm_vcpu *vcpu, int id)
uninit: uninit:
kvm_vcpu_uninit(vcpu); kvm_vcpu_uninit(vcpu);
fail: fail:
local_irq_restore(psr);
return r; return r;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment