summaryrefslogtreecommitdiff
path: root/virt
diff options
context:
space:
mode:
authorZenghui Yu <yuzenghui@huawei.com>2020-04-14 06:03:48 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-01 14:14:42 +0300
commit7c451f583f547536854e9647fa9582e698bc111c (patch)
tree582ed75c502d7c905474aacbb0654188f6d11c18 /virt
parent82be3d65f4198d3958bd54de1cba193368a4b1a2 (diff)
downloadlinux-7c451f583f547536854e9647fa9582e698bc111c.tar.xz
KVM: arm64: vgic-its: Fix memory leak on the error path of vgic_add_lpi()
[ Upstream commit 57bdb436ce869a45881d8aa4bc5dac8e072dd2b6 ] If we're going to fail out the vgic_add_lpi(), let's make sure the allocated vgic_irq memory is also freed. Though it seems that both cases are unlikely to fail. Signed-off-by: Zenghui Yu <yuzenghui@huawei.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20200414030349.625-3-yuzenghui@huawei.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/vgic/vgic-its.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index 9295addea7ec..f139b1c62ca3 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -107,14 +107,21 @@ out_unlock:
* We "cache" the configuration table entries in our struct vgic_irq's.
* However we only have those structs for mapped IRQs, so we read in
* the respective config data from memory here upon mapping the LPI.
+ *
+ * Should any of these fail, behave as if we couldn't create the LPI
+ * by dropping the refcount and returning the error.
*/
ret = update_lpi_config(kvm, irq, NULL, false);
- if (ret)
+ if (ret) {
+ vgic_put_irq(kvm, irq);
return ERR_PTR(ret);
+ }
ret = vgic_v3_lpi_sync_pending_status(kvm, irq);
- if (ret)
+ if (ret) {
+ vgic_put_irq(kvm, irq);
return ERR_PTR(ret);
+ }
return irq;
}