mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
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>
This commit is contained in:
committed by
Linus Torvalds
parent
32a92f8c89
commit
189f164e57
@@ -764,7 +764,7 @@ static int coverage_start_fn(const struct decode_header *h, void *args)
|
||||
static int coverage_start(const union decode_item *table)
|
||||
{
|
||||
coverage.base = kmalloc_objs(struct coverage_entry,
|
||||
MAX_COVERAGE_ENTRIES, GFP_KERNEL);
|
||||
MAX_COVERAGE_ENTRIES);
|
||||
coverage.num_entries = 0;
|
||||
coverage.nesting = 0;
|
||||
return table_iter(table, coverage_start_fn, &coverage);
|
||||
|
||||
@@ -342,7 +342,7 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
|
||||
/* Allocate cluster boot configuration structs */
|
||||
nclusters = mips_cps_numclusters();
|
||||
mips_cps_cluster_bootcfg = kzalloc_objs(*mips_cps_cluster_bootcfg,
|
||||
nclusters, GFP_KERNEL);
|
||||
nclusters);
|
||||
if (!mips_cps_cluster_bootcfg)
|
||||
goto err_out;
|
||||
|
||||
@@ -368,8 +368,7 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
|
||||
int v;
|
||||
core_vpes = core_vpe_count(cl, c);
|
||||
core_bootcfg[c].vpe_config = kzalloc_objs(*core_bootcfg[c].vpe_config,
|
||||
core_vpes,
|
||||
GFP_KERNEL);
|
||||
core_vpes);
|
||||
for (v = 0; v < core_vpes; v++)
|
||||
cpumask_set_cpu(nvpe++, &mips_cps_cluster_bootcfg[cl].cpumask);
|
||||
if (!core_bootcfg[c].vpe_config)
|
||||
|
||||
@@ -913,8 +913,7 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
|
||||
vcpu_e500->gtlb_params[1].sets = 1;
|
||||
|
||||
vcpu_e500->gtlb_arch = kmalloc_objs(*vcpu_e500->gtlb_arch,
|
||||
KVM_E500_TLB0_SIZE + KVM_E500_TLB1_SIZE,
|
||||
GFP_KERNEL);
|
||||
KVM_E500_TLB0_SIZE + KVM_E500_TLB1_SIZE);
|
||||
if (!vcpu_e500->gtlb_arch)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -922,14 +921,12 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
|
||||
vcpu_e500->gtlb_offset[1] = KVM_E500_TLB0_SIZE;
|
||||
|
||||
vcpu_e500->gtlb_priv[0] = kzalloc_objs(struct tlbe_ref,
|
||||
vcpu_e500->gtlb_params[0].entries,
|
||||
GFP_KERNEL);
|
||||
vcpu_e500->gtlb_params[0].entries);
|
||||
if (!vcpu_e500->gtlb_priv[0])
|
||||
goto free_vcpu;
|
||||
|
||||
vcpu_e500->gtlb_priv[1] = kzalloc_objs(struct tlbe_ref,
|
||||
vcpu_e500->gtlb_params[1].entries,
|
||||
GFP_KERNEL);
|
||||
vcpu_e500->gtlb_params[1].entries);
|
||||
if (!vcpu_e500->gtlb_priv[1])
|
||||
goto free_vcpu;
|
||||
|
||||
|
||||
@@ -1699,8 +1699,7 @@ static int imc_mem_init(struct imc_pmu *pmu_ptr, struct device_node *parent,
|
||||
/* Needed for hotplug/migration */
|
||||
if (!per_nest_pmu_arr) {
|
||||
per_nest_pmu_arr = kzalloc_objs(struct imc_pmu *,
|
||||
get_max_nest_dev() + 1,
|
||||
GFP_KERNEL);
|
||||
get_max_nest_dev() + 1);
|
||||
if (!per_nest_pmu_arr)
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -2282,7 +2282,7 @@ static int spufs_switch_log_open(struct inode *inode, struct file *file)
|
||||
}
|
||||
|
||||
ctx->switch_log = kmalloc_flex(*ctx->switch_log, log,
|
||||
SWITCH_LOG_BUFSIZE, GFP_KERNEL);
|
||||
SWITCH_LOG_BUFSIZE);
|
||||
|
||||
if (!ctx->switch_log) {
|
||||
rc = -ENOMEM;
|
||||
|
||||
@@ -266,7 +266,7 @@ int __init opal_async_comp_init(void)
|
||||
|
||||
opal_max_async_tokens = be32_to_cpup(async);
|
||||
opal_async_tokens = kzalloc_objs(*opal_async_tokens,
|
||||
opal_max_async_tokens, GFP_KERNEL);
|
||||
opal_max_async_tokens);
|
||||
if (!opal_async_tokens) {
|
||||
err = -ENOMEM;
|
||||
goto out_opal_node;
|
||||
|
||||
@@ -314,8 +314,7 @@ retry:
|
||||
/* Allocate the groups before registering */
|
||||
for (idx = 0; idx < num_attrs; idx++) {
|
||||
papr_groups[idx].pg.attrs = kzalloc_objs(*papr_groups[idx].pg.attrs,
|
||||
KOBJ_MAX_ATTRS + 1,
|
||||
GFP_KERNEL);
|
||||
KOBJ_MAX_ATTRS + 1);
|
||||
if (!papr_groups[idx].pg.attrs)
|
||||
goto out_pgattrs;
|
||||
|
||||
|
||||
@@ -754,7 +754,7 @@ initialize_relocation_hashtable(unsigned int num_relocations,
|
||||
|
||||
/* Number of relocations may be large, so kvmalloc it */
|
||||
*relocation_hashtable = kvmalloc_objs(**relocation_hashtable,
|
||||
hashtable_size, GFP_KERNEL);
|
||||
hashtable_size);
|
||||
if (!*relocation_hashtable)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -353,7 +353,7 @@ static int kvm_sbi_ext_fwft_init(struct kvm_vcpu *vcpu)
|
||||
int i;
|
||||
|
||||
fwft->configs = kzalloc_objs(struct kvm_sbi_fwft_config,
|
||||
ARRAY_SIZE(features), GFP_KERNEL);
|
||||
ARRAY_SIZE(features));
|
||||
if (!fwft->configs)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -282,8 +282,7 @@ static int pai_alloc_cpu(struct perf_event *event, int cpu)
|
||||
need_paiext_cb = true;
|
||||
}
|
||||
cpump->save = kvmalloc_objs(struct pai_userdata,
|
||||
pai_pmu[idx].num_avail + 1,
|
||||
GFP_KERNEL);
|
||||
pai_pmu[idx].num_avail + 1);
|
||||
if (!cpump->area || !cpump->save ||
|
||||
(need_paiext_cb && !cpump->paiext_cb)) {
|
||||
pai_free(mp);
|
||||
|
||||
@@ -1070,7 +1070,7 @@ static int __init ubd_init(void)
|
||||
return -1;
|
||||
|
||||
irq_req_buffer = kmalloc_objs(struct io_thread_req *,
|
||||
UBD_REQ_BUFFER_SIZE, GFP_KERNEL);
|
||||
UBD_REQ_BUFFER_SIZE);
|
||||
irq_remainder = 0;
|
||||
|
||||
if (irq_req_buffer == NULL) {
|
||||
@@ -1078,7 +1078,7 @@ static int __init ubd_init(void)
|
||||
return -ENOMEM;
|
||||
}
|
||||
io_req_buffer = kmalloc_objs(struct io_thread_req *,
|
||||
UBD_REQ_BUFFER_SIZE, GFP_KERNEL);
|
||||
UBD_REQ_BUFFER_SIZE);
|
||||
|
||||
io_remainder = 0;
|
||||
|
||||
|
||||
@@ -515,7 +515,7 @@ static void uml_vfio_open_device(struct uml_vfio_device *dev)
|
||||
}
|
||||
|
||||
dev->intr_ctx = kmalloc_objs(struct uml_vfio_intr_ctx,
|
||||
dev->udev.irq_count, GFP_KERNEL);
|
||||
dev->udev.irq_count);
|
||||
if (!dev->intr_ctx) {
|
||||
pr_err("Failed to allocate interrupt context (%s)\n",
|
||||
dev->name);
|
||||
|
||||
@@ -7379,7 +7379,7 @@ static __always_inline int intel_pmu_init_hybrid(enum hybrid_pmu_type pmus)
|
||||
|
||||
x86_pmu.num_hybrid_pmus = hweight_long(pmus_mask);
|
||||
x86_pmu.hybrid_pmu = kzalloc_objs(struct x86_hybrid_pmu,
|
||||
x86_pmu.num_hybrid_pmus, GFP_KERNEL);
|
||||
x86_pmu.num_hybrid_pmus);
|
||||
if (!x86_pmu.hybrid_pmu)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -745,8 +745,7 @@ intel_uncore_generic_init_uncores(enum uncore_access_type type_id, int num_extra
|
||||
int i = 0;
|
||||
|
||||
uncores = kzalloc_objs(struct intel_uncore_type *,
|
||||
num_discovered_types[type_id] + num_extra + 1,
|
||||
GFP_KERNEL);
|
||||
num_discovered_types[type_id] + num_extra + 1);
|
||||
if (!uncores)
|
||||
return empty_uncore;
|
||||
|
||||
|
||||
@@ -2407,7 +2407,7 @@ static int __tdx_td_init(struct kvm *kvm, struct td_params *td_params,
|
||||
/* TDVPS = TDVPR(4K page) + TDCX(multiple 4K pages), -1 for TDVPR. */
|
||||
kvm_tdx->td.tdcx_nr_pages = tdx_sysinfo->td_ctrl.tdvps_base_size / PAGE_SIZE - 1;
|
||||
tdcs_pages = kzalloc_objs(*kvm_tdx->td.tdcs_pages,
|
||||
kvm_tdx->td.tdcs_nr_pages, GFP_KERNEL);
|
||||
kvm_tdx->td.tdcs_nr_pages);
|
||||
if (!tdcs_pages)
|
||||
goto free_tdr;
|
||||
|
||||
|
||||
@@ -574,7 +574,7 @@ static int blk_crypto_fallback_init(void)
|
||||
goto fail_destroy_profile;
|
||||
|
||||
blk_crypto_keyslots = kzalloc_objs(blk_crypto_keyslots[0],
|
||||
blk_crypto_num_keyslots, GFP_KERNEL);
|
||||
blk_crypto_num_keyslots);
|
||||
if (!blk_crypto_keyslots)
|
||||
goto fail_free_wq;
|
||||
|
||||
|
||||
+1
-1
@@ -1805,7 +1805,7 @@ static int disk_alloc_zone_resources(struct gendisk *disk,
|
||||
|
||||
disk->zone_wplugs_hash =
|
||||
kzalloc_objs(struct hlist_head,
|
||||
disk_zone_wplugs_hash_size(disk), GFP_KERNEL);
|
||||
disk_zone_wplugs_hash_size(disk));
|
||||
if (!disk->zone_wplugs_hash)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -210,8 +210,7 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx)
|
||||
atomic_set(&ctx->thread_ctx_switch_token, 1);
|
||||
ctx->thread_ctx_switch_wait_token = 0;
|
||||
ctx->cs_pending = kzalloc_objs(struct hl_fence *,
|
||||
hdev->asic_prop.max_pending_cs,
|
||||
GFP_KERNEL);
|
||||
hdev->asic_prop.max_pending_cs);
|
||||
if (!ctx->cs_pending)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -893,8 +893,7 @@ static int device_early_init(struct hl_device *hdev)
|
||||
|
||||
if (hdev->asic_prop.completion_queues_count) {
|
||||
hdev->cq_wq = kzalloc_objs(struct workqueue_struct *,
|
||||
hdev->asic_prop.completion_queues_count,
|
||||
GFP_KERNEL);
|
||||
hdev->asic_prop.completion_queues_count);
|
||||
if (!hdev->cq_wq) {
|
||||
rc = -ENOMEM;
|
||||
goto asid_fini;
|
||||
@@ -2159,8 +2158,7 @@ int hl_device_init(struct hl_device *hdev)
|
||||
|
||||
if (user_interrupt_cnt) {
|
||||
hdev->user_interrupt = kzalloc_objs(*hdev->user_interrupt,
|
||||
user_interrupt_cnt,
|
||||
GFP_KERNEL);
|
||||
user_interrupt_cnt);
|
||||
if (!hdev->user_interrupt) {
|
||||
rc = -ENOMEM;
|
||||
goto early_fini;
|
||||
@@ -2227,7 +2225,7 @@ int hl_device_init(struct hl_device *hdev)
|
||||
*/
|
||||
if (cq_cnt) {
|
||||
hdev->completion_queue = kzalloc_objs(*hdev->completion_queue,
|
||||
cq_cnt, GFP_KERNEL);
|
||||
cq_cnt);
|
||||
|
||||
if (!hdev->completion_queue) {
|
||||
dev_err(hdev->dev,
|
||||
@@ -2249,8 +2247,7 @@ int hl_device_init(struct hl_device *hdev)
|
||||
}
|
||||
|
||||
hdev->shadow_cs_queue = kzalloc_objs(struct hl_cs *,
|
||||
hdev->asic_prop.max_pending_cs,
|
||||
GFP_KERNEL);
|
||||
hdev->asic_prop.max_pending_cs);
|
||||
if (!hdev->shadow_cs_queue) {
|
||||
rc = -ENOMEM;
|
||||
goto cq_fini;
|
||||
|
||||
@@ -1083,7 +1083,7 @@ int hl_hw_queues_create(struct hl_device *hdev)
|
||||
int i, rc, q_ready_cnt;
|
||||
|
||||
hdev->kernel_queues = kzalloc_objs(*hdev->kernel_queues,
|
||||
asic->max_queues, GFP_KERNEL);
|
||||
asic->max_queues);
|
||||
|
||||
if (!hdev->kernel_queues) {
|
||||
dev_err(hdev->dev, "Not enough memory for H/W queues\n");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user