Re: [PATCH v2 2/4] KVM: arm64: vgic: Don't leak the SPI array when init is retried

Fuad Tabba <[email protected]>
Newsgroups dev.linux.lists.kvmarm,dev.linux.lists.sashiko-reviews
Message-ID <CA+EHjTyDix+y6NTLTsXP5j9Sn2VLOZcsw94LntQxg_etRBJZuA@mail.gmail.com>
Hi again Marc,

On Mon, 17 Aug 2026 at 19:40, Fuad Tabba <[email protected]> wrote:
...
> > I really don't want to have to think about the intermediate state.
>
> Agreed. I'll drop the idempotent version I sketched and do teardown
> and reinit instead.

Here are my thoughts. Three patches, all fixes.

vgic_init() will undo what it created when it fails, so
KVM_DEV_ARM_VGIC_CTRL_INIT is all or nothing and a retry starts from
scratch. Same thing you asked Karl for on the redistributor rollback
[1].

That drops the count check I sketched. vgic_v4_init()'s early return
stays, since vgic_its_create() still calls it for an ITS created after
init.

irq-gic-v4.c goes first, as two patches. It removes the domains and
frees the fwnodes without clearing the pointers, at four sites, and
the teardown above makes that reachable on a path where it was not.
The second is a leak in the same error path: when
its_alloc_vcpu_sgis() fails partway, the SGI domains already allocated
below it are never unwound.

What do you think?
/fuad

[1] https://lore.kernel.org/all/[email protected]/
>
> Cheers,
> /fuad
>
> >
> > Thanks,
> >
> >         M.
> >
> > --
> > Jazz isn't dead. It just smells funny.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.