KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type
PATCH v2 1/1 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().
---
Cc: Marc Zyngier <[email protected]>
Cc: Oliver Upton <[email protected]>
Cc: Joey Gouly <[email protected]>
Cc: Suzuki K Poulose <[email protected]>
Cc: Zenghui Yu <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
--- arch/arm64/kvm/vgic/vgic-init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/vgic/vgic-init.c +1 -1
@@ -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; }
Signature · 1 line
2.34.1
Quoted 10 lines · Kees Cook
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 thesizeof().[...]
Applied to fixes, thanks!
[1/1] KVM: arm64: vgic: Handle const qualifier from gic_kvm_info allocation type
commit: ee5c38a8d31e5dea52299c43c2ec3213351ab6e1
Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Quoted 10 lines · Marc Zyngier
Quoted 9 lines · Kees Cook
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 thesizeof().
Quoted 6 lines
Quoted 1 line
[...]
Applied to fixes, thanks!
[1/1] KVM: arm64: vgic: Handle const qualifier from
gic_kvm_infoallocation typecommit: ee5c38a8d31e5dea52299c43c2ec3213351ab6e1
Just a heads-up that I ended up sending this patch to Linus for -rc1 as it was a prerequisite for the tree-wide kmalloc_obj refactoring. Sorry for any merge conflicts this might create for your tree! It is now commit c732084c891d there.
Signature · 1 line
Kees Cook
Marc Zyngier
maintainerQuoted 16 lines · Kees Cook
Quoted 14 lines · Marc Zyngier
Quoted 10 lines · Kees Cook
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 thesizeof().[...]
Applied to fixes, thanks!
Quoted 7 lines
Quoted 2 lines
[1/1] KVM: arm64: vgic: Handle const qualifier from
gic_kvm_infoallocation typecommit: ee5c38a8d31e5dea52299c43c2ec3213351ab6e1Just a heads-up that I ended up sending this patch to Linus for -rc1 as it was a prerequisite for the tree-wide
kmalloc_objrefactoring. Sorry for any merge conflicts this might create for your tree! It is now commitc732084c891dthere.
Yup, I noticed it this morning as I was preparing the first batch of fixes for KVM/arm64.
I'd appreciate it if in the future you would let me know upfront what route you expect a given patch to take -- I'll happily give an ack for a patch you want to route directly to Linus, rather than carrying it and ending up with conflicts with upstream.
Thanks,
M.
Signature · 1 line
Jazz isn't dead. It just smells funny.