summaryrefslogtreecommitdiff
path: root/kernel/liveupdate
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 /kernel/liveupdate
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 'kernel/liveupdate')
-rw-r--r--kernel/liveupdate/kexec_handover.c4
-rw-r--r--kernel/liveupdate/kexec_handover_debugfs.c2
-rw-r--r--kernel/liveupdate/luo_file.c4
-rw-r--r--kernel/liveupdate/luo_flb.c2
-rw-r--r--kernel/liveupdate/luo_session.c2
5 files changed, 7 insertions, 7 deletions
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 95601623b4d6..23d76678d233 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -187,7 +187,7 @@ static int __kho_preserve_order(struct kho_mem_track *track, unsigned long pfn,
if (!physxa) {
int err;
- new_physxa = kzalloc(sizeof(*physxa), GFP_KERNEL);
+ new_physxa = kzalloc_obj(*physxa, GFP_KERNEL);
if (!new_physxa)
return -ENOMEM;
@@ -1090,7 +1090,7 @@ void *kho_restore_vmalloc(const struct kho_vmalloc *preservation)
return NULL;
total_pages = preservation->total_pages;
- pages = kvmalloc_array(total_pages, sizeof(*pages), GFP_KERNEL);
+ pages = kvmalloc_objs(*pages, total_pages, GFP_KERNEL);
if (!pages)
return NULL;
order = preservation->order;
diff --git a/kernel/liveupdate/kexec_handover_debugfs.c b/kernel/liveupdate/kexec_handover_debugfs.c
index 2abbf62ba942..d42fc940d14d 100644
--- a/kernel/liveupdate/kexec_handover_debugfs.c
+++ b/kernel/liveupdate/kexec_handover_debugfs.c
@@ -29,7 +29,7 @@ static int __kho_debugfs_fdt_add(struct list_head *list, struct dentry *dir,
struct fdt_debugfs *f;
struct dentry *file;
- f = kmalloc(sizeof(*f), GFP_KERNEL);
+ f = kmalloc_obj(*f, GFP_KERNEL);
if (!f)
return -ENOMEM;
diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c
index 4c7df52a6507..ca96edb3b4e5 100644
--- a/kernel/liveupdate/luo_file.c
+++ b/kernel/liveupdate/luo_file.c
@@ -289,7 +289,7 @@ int luo_preserve_file(struct luo_file_set *file_set, u64 token, int fd)
if (err)
goto err_free_files_mem;
- luo_file = kzalloc(sizeof(*luo_file), GFP_KERNEL);
+ luo_file = kzalloc_obj(*luo_file, GFP_KERNEL);
if (!luo_file) {
err = -ENOMEM;
goto err_flb_unpreserve;
@@ -780,7 +780,7 @@ int luo_file_deserialize(struct luo_file_set *file_set,
return -ENOENT;
}
- luo_file = kzalloc(sizeof(*luo_file), GFP_KERNEL);
+ luo_file = kzalloc_obj(*luo_file, GFP_KERNEL);
if (!luo_file)
return -ENOMEM;
diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c
index 4c437de5c0b0..5f2cdf9caa7b 100644
--- a/kernel/liveupdate/luo_flb.c
+++ b/kernel/liveupdate/luo_flb.c
@@ -343,7 +343,7 @@ int liveupdate_register_flb(struct liveupdate_file_handler *fh,
if (WARN_ON(list_empty(&ACCESS_PRIVATE(fh, list))))
return -EINVAL;
- link = kzalloc(sizeof(*link), GFP_KERNEL);
+ link = kzalloc_obj(*link, GFP_KERNEL);
if (!link)
return -ENOMEM;
diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_session.c
index dbdbc3bd7929..c0262ca00533 100644
--- a/kernel/liveupdate/luo_session.c
+++ b/kernel/liveupdate/luo_session.c
@@ -119,7 +119,7 @@ static struct luo_session_global luo_session_global = {
static struct luo_session *luo_session_alloc(const char *name)
{
- struct luo_session *session = kzalloc(sizeof(*session), GFP_KERNEL);
+ struct luo_session *session = kzalloc_obj(*session, GFP_KERNEL);
if (!session)
return ERR_PTR(-ENOMEM);