summaryrefslogtreecommitdiff
path: root/arch/alpha/kernel
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /arch/alpha/kernel
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to avoid scalar types (which need careful case-by-case checking), and instead replace kmalloc-family calls that allocate struct or union object instances: Single allocations: kmalloc(sizeof(TYPE), ...) are replaced with: kmalloc_obj(TYPE, ...) Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...) are replaced with: kmalloc_objs(TYPE, COUNT, ...) Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...) are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...) (where TYPE may also be *VAR) The resulting allocations no longer return "void *", instead returning "TYPE *". Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'arch/alpha/kernel')
-rw-r--r--arch/alpha/kernel/core_marvel.c4
-rw-r--r--arch/alpha/kernel/core_titan.c4
-rw-r--r--arch/alpha/kernel/module.c4
-rw-r--r--arch/alpha/kernel/pci.c2
-rw-r--r--arch/alpha/kernel/setup.c2
5 files changed, 8 insertions, 8 deletions
diff --git a/arch/alpha/kernel/core_marvel.c b/arch/alpha/kernel/core_marvel.c
index d38f4d6759e4..b5b547732398 100644
--- a/arch/alpha/kernel/core_marvel.c
+++ b/arch/alpha/kernel/core_marvel.c
@@ -861,7 +861,7 @@ marvel_agp_setup(alpha_agp_info *agp)
if (!alpha_agpgart_size)
return -ENOMEM;
- aper = kmalloc(sizeof(*aper), GFP_KERNEL);
+ aper = kmalloc_obj(*aper, GFP_KERNEL);
if (aper == NULL) return -ENOMEM;
aper->arena = agp->hose->sg_pci;
@@ -1059,7 +1059,7 @@ marvel_agp_info(void)
/*
* Allocate the info structure.
*/
- agp = kmalloc(sizeof(*agp), GFP_KERNEL);
+ agp = kmalloc_obj(*agp, GFP_KERNEL);
if (!agp)
return NULL;
diff --git a/arch/alpha/kernel/core_titan.c b/arch/alpha/kernel/core_titan.c
index 77f5d68ed04b..ddaef7b75ba7 100644
--- a/arch/alpha/kernel/core_titan.c
+++ b/arch/alpha/kernel/core_titan.c
@@ -594,7 +594,7 @@ titan_agp_setup(alpha_agp_info *agp)
if (!alpha_agpgart_size)
return -ENOMEM;
- aper = kmalloc(sizeof(struct titan_agp_aperture), GFP_KERNEL);
+ aper = kmalloc_obj(struct titan_agp_aperture, GFP_KERNEL);
if (aper == NULL)
return -ENOMEM;
@@ -760,7 +760,7 @@ titan_agp_info(void)
/*
* Allocate the info structure.
*/
- agp = kmalloc(sizeof(*agp), GFP_KERNEL);
+ agp = kmalloc_obj(*agp, GFP_KERNEL);
if (!agp)
return NULL;
diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
index cbefa5a77384..6fbc2d179e93 100644
--- a/arch/alpha/kernel/module.c
+++ b/arch/alpha/kernel/module.c
@@ -46,7 +46,7 @@ process_reloc_for_got(Elf64_Rela *rela,
goto found_entry;
}
- g = kmalloc (sizeof (*g), GFP_KERNEL);
+ g = kmalloc_obj(*g, GFP_KERNEL);
g->next = chains[r_sym].next;
g->r_addend = r_addend;
g->got_offset = *poffset;
@@ -93,7 +93,7 @@ module_frob_arch_sections(Elf64_Ehdr *hdr, Elf64_Shdr *sechdrs,
}
nsyms = symtab->sh_size / sizeof(Elf64_Sym);
- chains = kcalloc(nsyms, sizeof(struct got_entry), GFP_KERNEL);
+ chains = kzalloc_objs(struct got_entry, nsyms, GFP_KERNEL);
if (!chains) {
printk(KERN_ERR
"module %s: no memory for symbol chain buffer\n",
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 8e9b4ac86b7e..93eb07018e6b 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -220,7 +220,7 @@ static void pdev_save_srm_config(struct pci_dev *dev)
printed = 1;
}
- tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
+ tmp = kmalloc_obj(*tmp, GFP_KERNEL);
if (!tmp) {
printk(KERN_ERR "%s: kmalloc() failed!\n", __func__);
return;
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index f0af444a69a4..ea4e7243c0e9 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -392,7 +392,7 @@ register_cpus(void)
int i;
for_each_possible_cpu(i) {
- struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
+ struct cpu *p = kzalloc_obj(*p, GFP_KERNEL);
if (!p)
return -ENOMEM;
register_cpu(p, i);