diff options
author | Eric Auger <eric.auger@redhat.com> | 2021-04-05 18:39:35 +0200 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2021-04-06 14:51:37 +0100 |
commit | 8542a8f95a67ff6b76d6868ec0af58c464bdf041 (patch) | |
tree | cf338577a14383db55c55a209c80ff30b63eb92c /arch/arm64/kvm | |
parent | 53b16dd6ba5cf64ed147ac3523ec34651d553cb0 (diff) | |
download | lwn-8542a8f95a67ff6b76d6868ec0af58c464bdf041.tar.gz lwn-8542a8f95a67ff6b76d6868ec0af58c464bdf041.zip |
KVM: arm64: vgic-v3: Fix error handling in vgic_v3_set_redist_base()
vgic_v3_insert_redist_region() may succeed while
vgic_register_all_redist_iodevs fails. For example this happens
while adding a redistributor region overlapping a dist region. The
failure only is detected on vgic_register_all_redist_iodevs when
vgic_v3_check_base() gets called in vgic_register_redist_iodev().
In such a case, remove the newly added redistributor region and free
it.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210405163941.510258-4-eric.auger@redhat.com
Diffstat (limited to 'arch/arm64/kvm')
-rw-r--r-- | arch/arm64/kvm/vgic/vgic-mmio-v3.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c index ef9baf0d01b5..fec0555529c0 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c @@ -861,8 +861,14 @@ int vgic_v3_set_redist_base(struct kvm *kvm, u32 index, u64 addr, u32 count) * afterwards will register the iodevs when needed. */ ret = vgic_register_all_redist_iodevs(kvm); - if (ret) + if (ret) { + struct vgic_redist_region *rdreg; + + rdreg = vgic_v3_rdist_region_from_index(kvm, index); + list_del(&rdreg->list); + kfree(rdreg); return ret; + } return 0; } |