diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-22 10:46:04 +0300 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-02-22 19:26:33 +0300 |
| commit | 189f164e573e18d9f8876dbd3ad8fcbe11f93037 (patch) | |
| tree | 733382723a15ea29b7c9f3dde3bcb281f0b3c287 /drivers/platform | |
| parent | 32a92f8c89326985e05dce8b22d3f0aa07a3e1bd (diff) | |
| download | linux-189f164e573e18d9f8876dbd3ad8fcbe11f93037.tar.xz | |
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 <kees@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/platform')
16 files changed, 16 insertions, 27 deletions
diff --git a/drivers/platform/x86/amd/wbrf.c b/drivers/platform/x86/amd/wbrf.c index b7556663223a..3281357185d1 100644 --- a/drivers/platform/x86/amd/wbrf.c +++ b/drivers/platform/x86/amd/wbrf.c @@ -73,8 +73,7 @@ static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran num_of_elements = 2 * num_of_ranges + 2; union acpi_object *tmp __free(kfree) = kzalloc_objs(*tmp, - num_of_elements, - GFP_KERNEL); + num_of_elements); if (!tmp) return -ENOMEM; diff --git a/drivers/platform/x86/dell/dell-wmi-base.c b/drivers/platform/x86/dell/dell-wmi-base.c index cdaa366b5e11..4eefbade2f5e 100644 --- a/drivers/platform/x86/dell/dell-wmi-base.c +++ b/drivers/platform/x86/dell/dell-wmi-base.c @@ -657,8 +657,7 @@ static int dell_wmi_input_setup(struct wmi_device *wdev) } keymap = kzalloc_objs(struct key_entry, - dmi_results.keymap_size + ARRAY_SIZE(dell_wmi_keymap_type_0000) + ARRAY_SIZE(dell_wmi_keymap_type_0010) + ARRAY_SIZE(dell_wmi_keymap_type_0011) + ARRAY_SIZE(dell_wmi_keymap_type_0012) + 1, - GFP_KERNEL); + dmi_results.keymap_size + ARRAY_SIZE(dell_wmi_keymap_type_0000) + ARRAY_SIZE(dell_wmi_keymap_type_0010) + ARRAY_SIZE(dell_wmi_keymap_type_0011) + ARRAY_SIZE(dell_wmi_keymap_type_0012) + 1); if (!keymap) { kfree(dmi_results.keymap); err = -ENOMEM; diff --git a/drivers/platform/x86/dell/dell-wmi-privacy.c b/drivers/platform/x86/dell/dell-wmi-privacy.c index 40fe2c4adedb..ed099a431ea4 100644 --- a/drivers/platform/x86/dell/dell-wmi-privacy.c +++ b/drivers/platform/x86/dell/dell-wmi-privacy.c @@ -315,7 +315,7 @@ static int dell_privacy_wmi_probe(struct wmi_device *wdev, const void *context) /* remap the wmi keymap event to new keymap */ keymap = kzalloc_objs(struct key_entry, - ARRAY_SIZE(dell_wmi_keymap_type_0012), GFP_KERNEL); + ARRAY_SIZE(dell_wmi_keymap_type_0012)); if (!keymap) return -ENOMEM; diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c index c7c55f8fe0a0..09996fbdc707 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c @@ -120,8 +120,7 @@ int alloc_enum_data(void) wmi_priv.enumeration_instances_count = get_instance_count(DELL_WMI_BIOS_ENUMERATION_ATTRIBUTE_GUID); wmi_priv.enumeration_data = kzalloc_objs(struct enumeration_data, - wmi_priv.enumeration_instances_count, - GFP_KERNEL); + wmi_priv.enumeration_instances_count); if (!wmi_priv.enumeration_data) { wmi_priv.enumeration_instances_count = 0; ret = -ENOMEM; diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c index f00a1cbac2f9..ab5c24722475 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c @@ -124,8 +124,7 @@ int alloc_int_data(void) wmi_priv.integer_instances_count = get_instance_count(DELL_WMI_BIOS_INTEGER_ATTRIBUTE_GUID); wmi_priv.integer_data = kzalloc_objs(struct integer_data, - wmi_priv.integer_instances_count, - GFP_KERNEL); + wmi_priv.integer_instances_count); if (!wmi_priv.integer_data) { wmi_priv.integer_instances_count = 0; ret = -ENOMEM; diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c index 44ecdcb82d84..be939b731063 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c @@ -144,7 +144,7 @@ int alloc_po_data(void) wmi_priv.po_instances_count = get_instance_count(DELL_WMI_BIOS_PASSOBJ_ATTRIBUTE_GUID); wmi_priv.po_data = kzalloc_objs(struct po_data, - wmi_priv.po_instances_count, GFP_KERNEL); + wmi_priv.po_instances_count); if (!wmi_priv.po_data) { wmi_priv.po_instances_count = 0; ret = -ENOMEM; diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c index 9e11c00ad859..41e19f0391b2 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c @@ -109,8 +109,7 @@ int alloc_str_data(void) wmi_priv.str_instances_count = get_instance_count(DELL_WMI_BIOS_STRING_ATTRIBUTE_GUID); wmi_priv.str_data = kzalloc_objs(struct str_data, - wmi_priv.str_instances_count, - GFP_KERNEL); + wmi_priv.str_instances_count); if (!wmi_priv.str_data) { wmi_priv.str_instances_count = 0; ret = -ENOMEM; diff --git a/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c index 4a09fd32ebc6..470b9f44ed7a 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c @@ -95,8 +95,7 @@ int hp_alloc_enumeration_data(void) hp_get_instance_count(HP_WMI_BIOS_ENUMERATION_GUID); bioscfg_drv.enumeration_data = kzalloc_objs(*bioscfg_drv.enumeration_data, - bioscfg_drv.enumeration_instances_count, - GFP_KERNEL); + bioscfg_drv.enumeration_instances_count); if (!bioscfg_drv.enumeration_data) { bioscfg_drv.enumeration_instances_count = 0; return -ENOMEM; diff --git a/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c index 84d522f2b491..d96e160953e3 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c @@ -110,8 +110,7 @@ int hp_alloc_integer_data(void) { bioscfg_drv.integer_instances_count = hp_get_instance_count(HP_WMI_BIOS_INTEGER_GUID); bioscfg_drv.integer_data = kzalloc_objs(*bioscfg_drv.integer_data, - bioscfg_drv.integer_instances_count, - GFP_KERNEL); + bioscfg_drv.integer_instances_count); if (!bioscfg_drv.integer_data) { bioscfg_drv.integer_instances_count = 0; diff --git a/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c index 592328280a81..f09489a085c8 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c @@ -99,8 +99,7 @@ int hp_alloc_ordered_list_data(void) bioscfg_drv.ordered_list_instances_count = hp_get_instance_count(HP_WMI_BIOS_ORDERED_LIST_GUID); bioscfg_drv.ordered_list_data = kzalloc_objs(*bioscfg_drv.ordered_list_data, - bioscfg_drv.ordered_list_instances_count, - GFP_KERNEL); + bioscfg_drv.ordered_list_instances_count); if (!bioscfg_drv.ordered_list_data) { bioscfg_drv.ordered_list_instances_count = 0; return -ENOMEM; diff --git a/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c index dc7107ff010b..4d79eb8056a5 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c @@ -186,8 +186,7 @@ int hp_alloc_password_data(void) { bioscfg_drv.password_instances_count = hp_get_instance_count(HP_WMI_BIOS_PASSWORD_GUID); bioscfg_drv.password_data = kzalloc_objs(*bioscfg_drv.password_data, - bioscfg_drv.password_instances_count, - GFP_KERNEL); + bioscfg_drv.password_instances_count); if (!bioscfg_drv.password_data) { bioscfg_drv.password_instances_count = 0; return -ENOMEM; diff --git a/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c index f0ce4f3e7f20..fe5a9a3a4ef1 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c @@ -102,8 +102,7 @@ int hp_alloc_string_data(void) { bioscfg_drv.string_instances_count = hp_get_instance_count(HP_WMI_BIOS_STRING_GUID); bioscfg_drv.string_data = kzalloc_objs(*bioscfg_drv.string_data, - bioscfg_drv.string_instances_count, - GFP_KERNEL); + bioscfg_drv.string_instances_count); if (!bioscfg_drv.string_data) { bioscfg_drv.string_instances_count = 0; return -ENOMEM; diff --git a/drivers/platform/x86/intel/int1092/intel_sar.c b/drivers/platform/x86/intel/int1092/intel_sar.c index fb26e5a26ffa..88822023a149 100644 --- a/drivers/platform/x86/intel/int1092/intel_sar.c +++ b/drivers/platform/x86/intel/int1092/intel_sar.c @@ -92,7 +92,7 @@ static acpi_status parse_package(struct wwan_sar_context *context, union acpi_ob return AE_ERROR; data->device_mode_info = kmalloc_objs(struct wwan_device_mode_info, - data->total_dev_mode, GFP_KERNEL); + data->total_dev_mode); if (!data->device_mode_info) return AE_ERROR; diff --git a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c index a38c278a792b..b8cdaa233ea9 100644 --- a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +++ b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c @@ -1820,7 +1820,7 @@ int tpmi_sst_init(void) } isst_common.sst_inst = kzalloc_objs(*isst_common.sst_inst, - topology_max_packages(), GFP_KERNEL); + topology_max_packages()); if (!isst_common.sst_inst) { ret = -ENOMEM; goto init_done; diff --git a/drivers/platform/x86/intel/tpmi_power_domains.c b/drivers/platform/x86/intel/tpmi_power_domains.c index 57c8856fc468..833052dc34d2 100644 --- a/drivers/platform/x86/intel/tpmi_power_domains.c +++ b/drivers/platform/x86/intel/tpmi_power_domains.c @@ -222,8 +222,7 @@ static int __init tpmi_init(void) return ret; tpmi_power_domain_mask = kzalloc_objs(*tpmi_power_domain_mask, - size_mul(topology_max_packages(), MAX_POWER_DOMAINS), - GFP_KERNEL); + size_mul(topology_max_packages(), MAX_POWER_DOMAINS)); if (!tpmi_power_domain_mask) return -ENOMEM; diff --git a/drivers/platform/x86/uv_sysfs.c b/drivers/platform/x86/uv_sysfs.c index b9adb34502bd..a8c50b323a9e 100644 --- a/drivers/platform/x86/uv_sysfs.c +++ b/drivers/platform/x86/uv_sysfs.c @@ -388,7 +388,7 @@ static int uv_ports_init(void) } for (j = 0; j < uv_bios_obj_cnt; j++) { uv_hubs[j]->ports = kzalloc_objs(*uv_hubs[j]->ports, - hub_buf[j].ports, GFP_KERNEL); + hub_buf[j].ports); if (!uv_hubs[j]->ports) { ret = -ENOMEM; j--; |
