Skip to content

Commit

Permalink
KVM: arm64: vgic-its: Fix memory leak on the error path of vgic_add_l…
Browse files Browse the repository at this point in the history
…pi()

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 <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
Zenghui Yu authored and Marc Zyngier committed Apr 23, 2020
1 parent 969ce8b commit 57bdb43
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions virt/kvm/arm/vgic/vgic-its.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* 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;
}
Expand Down

0 comments on commit 57bdb43

Please sign in to comment.