summaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorMiaohe Lin <linmiaohe@huawei.com>2019-11-28 14:38:48 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-01 13:14:29 +0200
commit8b3a8c6a73c589006eb5d29748f0b8a6c81f3fd6 (patch)
treea48fb55d0dec7096880e094afd4128c99bc65a3b /virt
parent489cee9124d53ce20fb3f989449efa2aa51a4b18 (diff)
downloadlinux-stable-8b3a8c6a73c589006eb5d29748f0b8a6c81f3fd6.tar.gz
linux-stable-8b3a8c6a73c589006eb5d29748f0b8a6c81f3fd6.tar.bz2
linux-stable-8b3a8c6a73c589006eb5d29748f0b8a6c81f3fd6.zip
KVM: arm/arm64: vgic: Fix potential double free dist->spis in __kvm_vgic_destroy()
[ Upstream commit 0bda9498dd45280e334bfe88b815ebf519602cc3 ] In kvm_vgic_dist_init() called from kvm_vgic_map_resources(), if dist->vgic_model is invalid, dist->spis will be freed without set dist->spis = NULL. And in vgicv2 resources clean up path, __kvm_vgic_destroy() will be called to free allocated resources. And dist->spis will be freed again in clean up chain because we forget to set dist->spis = NULL in kvm_vgic_dist_init() failed path. So double free would happen. Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Eric Auger <eric.auger@redhat.com> Link: https://lore.kernel.org/r/1574923128-19956-1-git-send-email-linmiaohe@huawei.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/vgic/vgic-init.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
index cd75df25fe14..2fc1777da50d 100644
--- a/virt/kvm/arm/vgic/vgic-init.c
+++ b/virt/kvm/arm/vgic/vgic-init.c
@@ -187,6 +187,7 @@ static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis)
break;
default:
kfree(dist->spis);
+ dist->spis = NULL;
return -EINVAL;
}
}