[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <610f2195-f85d-4beb-b711-47d63bb393d0@huawei.com>
Date: Thu, 16 Apr 2020 09:17:54 +0800
From: Zenghui Yu <yuzenghui@...wei.com>
To: <kvmarm@...ts.cs.columbia.edu>
CC: <maz@...nel.org>, <james.morse@....com>,
<julien.thierry.kdev@...il.com>, <suzuki.poulose@....com>,
<wanghaibin.wang@...wei.com>, <yezengruan@...wei.com>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] KVM: arm64: vgic-its: Fix memory leak on the error
path of vgic_add_lpi()
On 2020/4/14 11:03, Zenghui Yu wrote:
> 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.
>
> Cc: Zengruan Ye <yezengruan@...wei.com>
> Signed-off-by: Zenghui Yu <yuzenghui@...wei.com>
> ---
> virt/kvm/arm/vgic/vgic-its.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
> index d53d34a33e35..3c3b6a0f2dce 100644
> --- a/virt/kvm/arm/vgic/vgic-its.c
> +++ b/virt/kvm/arm/vgic/vgic-its.c
> @@ -98,12 +98,16 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
> * the respective config data from memory here upon mapping the LPI.
> */
> ret = update_lpi_config(kvm, irq, NULL, false);
> - if (ret)
> + if (ret) {
> + kfree(irq);
> return ERR_PTR(ret);
> + }
>
> ret = vgic_v3_lpi_sync_pending_status(kvm, irq);
> - if (ret)
> + if (ret) {
> + kfree(irq);
> return ERR_PTR(ret);
> + }
Looking at it again, I realized that this error handling is still not
complete. Maybe we should use a vgic_put_irq() instead so that we can
also properly delete the vgic_irq from lpi_list.
Marc, what do you think? Could you please help to fix it, or I can
resend it.
Thanks,
Zenghui
Powered by blists - more mailing lists