* [PATCH] klp-build: Use kzalloc_objs() for object and function arrays
@ 2026-10-20 7:27 Hungyu Lin
0 siblings, 0 replies; only message in thread
From: Hungyu Lin @ 2026-10-20 7:27 UTC (permalink / raw)
To: Josh Poimboeuf
Cc: Miroslav Benes, Petr Mladek, Joe Lawrence, Song Liu,
live-patching, linux-kernel, Hungyu Lin
Allocate the object and function arrays with kzalloc_objs() so their
element sizes are derived from the destination types and multiplication
overflow is handled by the allocation helper.
Keep the extra zeroed entry used to terminate each array. The default
allocation flags remain GFP_KERNEL.
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
scripts/livepatch/init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/livepatch/init.c b/scripts/livepatch/init.c
index f14d8c8fb35f..908676d6d07d 100644
--- a/scripts/livepatch/init.c
+++ b/scripts/livepatch/init.c
@@ -34,7 +34,7 @@ static int __init livepatch_mod_init(void)
goto err;
}
- objs = kzalloc(sizeof(struct klp_object) * (nr_objs + 1), GFP_KERNEL);
+ objs = kzalloc_objs(*objs, nr_objs + 1);
if (!objs) {
ret = -ENOMEM;
goto err_free_patch;
@@ -47,7 +47,7 @@ static int __init livepatch_mod_init(void)
struct klp_func *funcs = objs[i].funcs;
struct klp_object *obj = objs + i;
- funcs = kzalloc(sizeof(struct klp_func) * (nr_funcs + 1), GFP_KERNEL);
+ funcs = kzalloc_objs(*funcs, nr_funcs + 1);
if (!funcs) {
ret = -ENOMEM;
for (int j = 0; j < i; j++)
base-commit: f663062d717eac2c01f77eaf321fa630528e672d
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-20 7:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-20 7:27 [PATCH] klp-build: Use kzalloc_objs() for object and function arrays Hungyu Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®