From: Shihao Ren <rsh15355756202@163.com>
To: jpoimboe@kernel.org, jikos@kernel.org, mbenes@suse.cz, pmladek@suse.com
Cc: joe.lawrence@redhat.com, live-patching@vger.kernel.org,
linux-kernel@vger.kernel.org, Shihao Ren <rsh15355756202@163.com>
Subject: [PATCH] livepatch/klp-build: Fix wrong index in error cleanup loop
Date: Wed, 1 Jul 2026 14:06:55 +0800 [thread overview]
Message-ID: <20260701060655.2343093-1-rsh15355756202@163.com> (raw)
In the funcs allocation failure path, the cleanup loop iterates with
'j' but frees objs[i].funcs, which uses the outer loop index 'i'
instead of the loop variable 'j'. As a result the just-failed (NULL)
entry is freed repeatedly, while the funcs buffers already allocated
for objs[0..i-1] are leaked.
Use objs[j].funcs so the previously allocated entries are correctly
released.
Fixes: 59adee07b568 ("livepatch/klp-build: Add stub init code for livepatch modules")
Signed-off-by: Shihao Ren <rsh15355756202@163.com>
---
scripts/livepatch/init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/livepatch/init.c b/scripts/livepatch/init.c
index f14d8c8fb..16aff8f73 100644
--- a/scripts/livepatch/init.c
+++ b/scripts/livepatch/init.c
@@ -51,7 +51,7 @@ static int __init livepatch_mod_init(void)
if (!funcs) {
ret = -ENOMEM;
for (int j = 0; j < i; j++)
- kfree(objs[i].funcs);
+ kfree(objs[j].funcs);
goto err_free_objs;
}
--
2.39.5
next reply other threads:[~2026-07-01 6:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 6:06 Shihao Ren [this message]
2026-07-01 11:16 ` [PATCH] livepatch/klp-build: Fix wrong index in error cleanup loop Miroslav Benes
2026-07-02 8:53 ` Petr Mladek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260701060655.2343093-1-rsh15355756202@163.com \
--to=rsh15355756202@163.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=pmladek@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox