[PATCH] KVM: arm64: vgic: Handle const qualifier from clusters allocation type
Kees Cook
kees at kernel.org
Fri Feb 6 14:29:40 PST 2026
Oops, bad Subject... sending v2
On Fri, Feb 06, 2026 at 02:26:53PM -0800, Kees Cook wrote:
> 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 at kernel.org>
> ---
> Cc: Marc Zyngier <maz at kernel.org>
> Cc: Oliver Upton <oupton at kernel.org>
> Cc: Joey Gouly <joey.gouly at arm.com>
> Cc: Suzuki K Poulose <suzuki.poulose at arm.com>
> Cc: Zenghui Yu <yuzenghui at huawei.com>
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> Cc: Will Deacon <will at kernel.org>
> Cc: Alexander Potapenko <glider at google.com>
> Cc: <linux-arm-kernel at lists.infradead.org>
> Cc: <kvmarm at lists.linux.dev>
> ---
> arch/arm64/kvm/vgic/vgic-init.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c
> index 86c149537493..a53f93546aa0 100644
> --- a/arch/arm64/kvm/vgic/vgic-init.c
> +++ b/arch/arm64/kvm/vgic/vgic-init.c
> @@ -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;
> }
> --
> 2.34.1
>
--
Kees Cook
More information about the linux-arm-kernel
mailing list