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/pps | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.zip | |
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/pps')
| -rw-r--r-- | drivers/pps/clients/pps_parport.c | 2 | ||||
| -rw-r--r-- | drivers/pps/generators/pps_gen.c | 2 | ||||
| -rw-r--r-- | drivers/pps/kapi.c | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/drivers/pps/clients/pps_parport.c b/drivers/pps/clients/pps_parport.c index 24db06750297..975d984b0fd5 100644 --- a/drivers/pps/clients/pps_parport.c +++ b/drivers/pps/clients/pps_parport.c @@ -142,7 +142,7 @@ static void parport_attach(struct parport *port) return; } - device = kzalloc(sizeof(struct pps_client_pp), GFP_KERNEL); + device = kzalloc_obj(struct pps_client_pp, GFP_KERNEL); if (!device) { pr_err("memory allocation failed, not attaching\n"); return; diff --git a/drivers/pps/generators/pps_gen.c b/drivers/pps/generators/pps_gen.c index 5b8bb454913c..a91f6871f98a 100644 --- a/drivers/pps/generators/pps_gen.c +++ b/drivers/pps/generators/pps_gen.c @@ -230,7 +230,7 @@ struct pps_gen_device *pps_gen_register_source(const struct pps_gen_source_info struct pps_gen_device *pps_gen; int err; - pps_gen = kzalloc(sizeof(struct pps_gen_device), GFP_KERNEL); + pps_gen = kzalloc_obj(struct pps_gen_device, GFP_KERNEL); if (pps_gen == NULL) { err = -ENOMEM; goto pps_gen_register_source_exit; diff --git a/drivers/pps/kapi.c b/drivers/pps/kapi.c index 6985c34de2ce..de2ce4faf262 100644 --- a/drivers/pps/kapi.c +++ b/drivers/pps/kapi.c @@ -83,7 +83,7 @@ struct pps_device *pps_register_source(struct pps_source_info *info, } /* Allocate memory for the new PPS source struct */ - pps = kzalloc(sizeof(struct pps_device), GFP_KERNEL); + pps = kzalloc_obj(struct pps_device, GFP_KERNEL); if (pps == NULL) { err = -ENOMEM; goto pps_register_source_exit; |
