Skip to content

Commit

Permalink
KVM: arm/arm64: Set dist->spis to NULL after kfree
Browse files Browse the repository at this point in the history
in case kvm_vgic_map_resources() fails, typically if the vgic
distributor is not defined, __kvm_vgic_destroy will be called
several times. Indeed kvm_vgic_map_resources() is called on
first vcpu run. As a result dist->spis is freeed more than once
and on the second time it causes a "kernel BUG at mm/slub.c:3912!"

Set dist->spis to NULL to avoid the crash.

Fixes: ad275b8 ("KVM: arm/arm64: vgic-new: vgic_init: implement
vgic_init")

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
  • Loading branch information
Eric Auger authored and Marc Zyngier committed May 25, 2018
1 parent cf412b0 commit 9153ab7
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions virt/kvm/arm/vgic/vgic-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ static void kvm_vgic_dist_destroy(struct kvm *kvm)
dist->initialized = false;

kfree(dist->spis);
dist->spis = NULL;
dist->nr_spis = 0;

if (vgic_supports_direct_msis(kvm))
Expand Down

0 comments on commit 9153ab7

Please sign in to comment.