Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type

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().

Signed-off-by: Kees Cook <kees@kernel.org>
Link: https://patch.msgid.link/20260206223022.it.052-kees@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>

authored by

Kees Cook and committed by
Marc Zyngier
ee5c38a8 02471a78

+1 -1
+1 -1
arch/arm64/kvm/vgic/vgic-init.c
··· 654 654 void __init vgic_set_kvm_info(const struct gic_kvm_info *info) 655 655 { 656 656 BUG_ON(gic_kvm_info != NULL); 657 - gic_kvm_info = kmalloc(sizeof(*info), GFP_KERNEL); 657 + gic_kvm_info = kmalloc(sizeof(*gic_kvm_info), GFP_KERNEL); 658 658 if (gic_kvm_info) 659 659 *gic_kvm_info = *info; 660 660 }