Commit 57bdb436 authored by Zenghui Yu's avatar Zenghui Yu Committed by Marc Zyngier

KVM: arm64: vgic-its: Fix memory leak on the error path of vgic_add_lpi()

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: default avatarZenghui Yu <yuzenghui@huawei.com>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20200414030349.625-3-yuzenghui@huawei.com
parent 969ce8b5
...@@ -96,14 +96,21 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid, ...@@ -96,14 +96,21 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
* We "cache" the configuration table entries in our struct vgic_irq's. * 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 * However we only have those structs for mapped IRQs, so we read in
* the respective config data from memory here upon mapping the LPI. * 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); ret = update_lpi_config(kvm, irq, NULL, false);
if (ret) if (ret) {
vgic_put_irq(kvm, irq);
return ERR_PTR(ret); return ERR_PTR(ret);
}
ret = vgic_v3_lpi_sync_pending_status(kvm, irq); ret = vgic_v3_lpi_sync_pending_status(kvm, irq);
if (ret) if (ret) {
vgic_put_irq(kvm, irq);
return ERR_PTR(ret); return ERR_PTR(ret);
}
return irq; return irq;
} }
......
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