Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Jackie Liu" <liu.yun@linux.dev>
To: "Oliver Upton" <oupton@kernel.org>
Cc: maz@kernel.org, linux-arm-kernel@lists.infradead.org,
	yuzenghui@huawei.com, will@kernel.org, kvmarm@lists.linux.dev
Subject: Re: [PATCH] KVM/arm64: vgic-its: Fix memory leak when vgic_its_set_abi() fails
Date: Thu, 04 Jun 2026 06:59:49 +0000	[thread overview]
Message-ID: <0bc286797b469d93631cb3ad2c99e135f49d5200@linux.dev> (raw)
In-Reply-To: <aiEeKGsLg9098OUt@kernel.org>

2026年6月4日 14:41, "Oliver Upton" <oupton@kernel.org mailto:oupton@kernel.org?to=%22Oliver%20Upton%22%20%3Coupton%40kernel.org%3E > 写到:


> 
> On Thu, Jun 04, 2026 at 11:14:26AM +0800, Jackie Liu wrote:
> 
> > 
> > From: Jackie Liu <liuyun01@kylinos.cn>
> >  
> >  In vgic_its_create(), if vgic_its_set_abi() fails after allocating the
> >  its structure and setting kvm state, the allocated 'its' is leaked
> >  because the function returns without freeing it.
> >  
> >  Fix by rolling back the kvm state flags and freeing the its structure
> >  when vgic_its_set_abi() returns an error.
> >  
> >  Fixes: 71afe470e20d ("KVM: arm64: vgic-its: Introduce migration ABI infrastructure")
> >  Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> > 
> vgic_its_set_abi() always succeeds so there's no actual memory leak
> here. I'd prefer getting rid of the return value instead.

That was my original thought as well. However, I kept the defensive cleanup logic in place
to make future extensions easier. This way, if additional resource allocation paths are 
introduced later, we're less likely to miss the corresponding cleanup.

That said, looking at the current code, the return value no longer serves any real 
purpose, so removing it would also be a reasonable and cleaner approach.

I'll send a V2 with this change.

Thanks.
Jackie


> 
> Thanks,
> Oliver
>


      reply	other threads:[~2026-06-04  7:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-04  3:14 [PATCH] KVM/arm64: vgic-its: Fix memory leak when vgic_its_set_abi() fails Jackie Liu
2026-06-04  6:41 ` Oliver Upton
2026-06-04  6:59   ` Jackie Liu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0bc286797b469d93631cb3ad2c99e135f49d5200@linux.dev \
    --to=liu.yun@linux.dev \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox