[PATCH] KVM/arm64: vgic-its: Fix memory leak when vgic_its_set_abi() fails

Jackie Liu liu.yun at linux.dev
Wed Jun 3 23:59:49 PDT 2026


2026年6月4日 14:41, "Oliver Upton" <oupton at kernel.org mailto:oupton at 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 at 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 at 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
>



More information about the linux-arm-kernel mailing list