diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/of/overlay.c | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (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 'drivers/of/overlay.c')
| -rw-r--r-- | drivers/of/overlay.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 5b4f42230e6c..87faec65c865 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -248,7 +248,7 @@ static struct property *dup_and_fixup_symbol_prop( return NULL; target_path_len = strlen(target_path); - new_prop = kzalloc(sizeof(*new_prop), GFP_KERNEL); + new_prop = kzalloc_obj(*new_prop, GFP_KERNEL); if (!new_prop) goto err_free_target_path; @@ -784,7 +784,7 @@ static int init_overlay_changeset(struct overlay_changeset *ovcs, of_node_put(node); } - fragments = kcalloc(cnt, sizeof(*fragments), GFP_KERNEL); + fragments = kzalloc_objs(*fragments, cnt, GFP_KERNEL); if (!fragments) { ret = -ENOMEM; goto err_out; @@ -1009,7 +1009,7 @@ int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size, if (overlay_fdt_size < size) return -EINVAL; - ovcs = kzalloc(sizeof(*ovcs), GFP_KERNEL); + ovcs = kzalloc_obj(*ovcs, GFP_KERNEL); if (!ovcs) return -ENOMEM; |
