KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type
authorKees Cook <kees@kernel.org>
Fri, 6 Feb 2026 22:30:23 +0000 (14:30 -0800)
committerKees Cook <kees@kernel.org>
Thu, 19 Feb 2026 18:14:02 +0000 (10:14 -0800)
In preparation for making the kmalloc family of allocators type aware,
we need to make sure that the returned type from the allocation matches
the type of the variable being assigned. (Before, the allocator would
always return "void *", which can be implicitly cast to any pointer type.)

The assigned type is "struct gic_kvm_info", but the returned type,
while matching, is const qualified. To get them exactly matching, just
use the dereferenced pointer for the sizeof().

Link: https://patch.msgid.link/20260206223022.it.052-kees@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
arch/arm64/kvm/vgic/vgic-init.c

index 86c1495..a53f935 100644 (file)
@@ -654,7 +654,7 @@ static struct gic_kvm_info *gic_kvm_info;
 void __init vgic_set_kvm_info(const struct gic_kvm_info *info)
 {
        BUG_ON(gic_kvm_info != NULL);
-       gic_kvm_info = kmalloc(sizeof(*info), GFP_KERNEL);
+       gic_kvm_info = kmalloc(sizeof(*gic_kvm_info), GFP_KERNEL);
        if (gic_kvm_info)
                *gic_kvm_info = *info;
 }