[PATCH v2 1/4] KVM: arm64: vgic: Free gic_kvm_info on initialization failure
Joey Gouly
joey.gouly at arm.com
Wed Aug 12 06:14:15 PDT 2026
On Tue, Aug 11, 2026 at 03:10:17PM +0000, Sascha Bischoff wrote:
> vgic_set_kvm_info() allocates gic_kvm_info for use by
> kvm_vgic_hyp_init(). When a maintenance interrupt is mandatory but not
> provided, kvm_vgic_hyp_init() returns -ENXIO before reaching the
> common cleanup path, leaking said allocation.
>
> Route this error through that cleanup path so that gic_kvm_info is
> freed and the global pointer is cleared.
>
> Fixes: 0e5cb7770684 ("irqchip/gic: Split vGIC probing information from the GIC code")
> Link: https://sashiko.dev/#/patchset/20260724104819.1296803-1-sascha.bischoff@arm.com?part=1
> Signed-off-by: Sascha Bischoff <sascha.bischoff at arm.com>
> ---
> arch/arm64/kvm/vgic/vgic-init.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c
> index 907057881b26a..65e203d6a2cf4 100644
> --- a/arch/arm64/kvm/vgic/vgic-init.c
> +++ b/arch/arm64/kvm/vgic/vgic-init.c
> @@ -787,7 +787,8 @@ int kvm_vgic_hyp_init(void)
>
> if (has_mask && !gic_kvm_info->maint_irq) {
> kvm_err("No vgic maintenance irq\n");
> - return -ENXIO;
> + ret = -ENXIO;
> + goto out_free;
> }
>
> /*
> @@ -820,6 +821,7 @@ int kvm_vgic_hyp_init(void)
>
> kvm_vgic_global_state.maint_irq = gic_kvm_info->maint_irq;
>
> +out_free:
> kfree(gic_kvm_info);
> gic_kvm_info = NULL;
>
Reviewed-by: Joey Gouly <joey.gouly at arm.com>
More information about the linux-arm-kernel
mailing list