From 189f164e573e18d9f8876dbd3ad8fcbe11f93037 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Sat, 21 Feb 2026 23:46:04 -0800 Subject: Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses Conversion performed via this Coccinelle script: // SPDX-License-Identifier: GPL-2.0-only // Options: --include-headers-for-types --all-includes --include-headers --keep-comments virtual patch @gfp depends on patch && !(file in "tools") && !(file in "samples")@ identifier ALLOC = {kmalloc_obj,kmalloc_objs,kmalloc_flex, kzalloc_obj,kzalloc_objs,kzalloc_flex, kvmalloc_obj,kvmalloc_objs,kvmalloc_flex, kvzalloc_obj,kvzalloc_objs,kvzalloc_flex}; @@ ALLOC(... - , GFP_KERNEL ) $ make coccicheck MODE=patch COCCI=gfp.cocci Build and boot tested x86_64 with Fedora 42's GCC and Clang: Linux version 6.19.0+ (user@host) (gcc (GCC) 15.2.1 20260123 (Red Hat 15.2.1-7), GNU ld version 2.44-12.fc42) #1 SMP PREEMPT_DYNAMIC 1970-01-01 Linux version 6.19.0+ (user@host) (clang version 20.1.8 (Fedora 20.1.8-4.fc42), LLD 20.1.8) #1 SMP PREEMPT_DYNAMIC 1970-01-01 Signed-off-by: Kees Cook Signed-off-by: Linus Torvalds --- drivers/xen/events/events_base.c | 3 +-- drivers/xen/gntdev-dmabuf.c | 2 +- drivers/xen/xen-acpi-processor.c | 2 +- drivers/xen/xen-front-pgdir-shbuf.c | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers/xen') diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 679e807c3663..bc9a41662efc 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -2293,8 +2293,7 @@ void __init xen_init_IRQ(void) xen_evtchn_cpu_prepare, xen_evtchn_cpu_dead); evtchn_to_irq = kzalloc_objs(*evtchn_to_irq, - EVTCHN_ROW(xen_evtchn_max_channels()), - GFP_KERNEL); + EVTCHN_ROW(xen_evtchn_max_channels())); BUG_ON(!evtchn_to_irq); /* No event channels are 'live' right now. */ diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c index 4a6f4325ad04..83b0df460894 100644 --- a/drivers/xen/gntdev-dmabuf.c +++ b/drivers/xen/gntdev-dmabuf.c @@ -535,7 +535,7 @@ static struct gntdev_dmabuf *dmabuf_imp_alloc_storage(int count) goto fail_no_free; gntdev_dmabuf->u.imp.refs = kzalloc_objs(gntdev_dmabuf->u.imp.refs[0], - count, GFP_KERNEL); + count); if (!gntdev_dmabuf->u.imp.refs) goto fail; diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c index a395b382c649..31903bfdce9f 100644 --- a/drivers/xen/xen-acpi-processor.c +++ b/drivers/xen/xen-acpi-processor.c @@ -142,7 +142,7 @@ xen_copy_pss_data(struct acpi_processor *_pr, sizeof(struct acpi_processor_px)); dst_states = kzalloc_objs(struct xen_processor_px, - _pr->performance->state_count, GFP_KERNEL); + _pr->performance->state_count); if (!dst_states) return ERR_PTR(-ENOMEM); diff --git a/drivers/xen/xen-front-pgdir-shbuf.c b/drivers/xen/xen-front-pgdir-shbuf.c index f693b963a2e8..9c7d8af6e6a1 100644 --- a/drivers/xen/xen-front-pgdir-shbuf.c +++ b/drivers/xen/xen-front-pgdir-shbuf.c @@ -254,7 +254,7 @@ static int backend_map(struct xen_front_pgdir_shbuf *buf) return -ENOMEM; buf->backend_map_handles = kzalloc_objs(*buf->backend_map_handles, - buf->num_pages, GFP_KERNEL); + buf->num_pages); if (!buf->backend_map_handles) { kfree(map_ops); return -ENOMEM; -- cgit v1.2.3