[PATCH v11 4/9] livepatch: Call klp_init_patch_early() earlier
From: Yafang Shao
Date: Thu Oct 08 2026 - 06:00:23 EST
Invoke klp_init_patch_early() during early initialization to avoid
mixing for_each_() and for_each_*_static() variants later in the code.
No functional change. This prepares the code for an upcoming patch.
Suggested-by: Petr Mladek <pmladek@xxxxxxxx>
Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx>
Acked-by: Song Liu <song@xxxxxxxxxx>
Acked-by: Miroslav Benes <mbenes@xxxxxxx>
Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
---
kernel/livepatch/core.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 89251fafe86e..c0879b5d9dc0 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -1155,13 +1155,6 @@ int klp_enable_patch(struct klp_patch *patch)
mutex_lock(&klp_mutex);
- if (!klp_is_patch_compatible(patch)) {
- pr_err("Livepatch patch (%s) is not compatible with the already installed livepatches.\n",
- patch->mod->name);
- mutex_unlock(&klp_mutex);
- return -EINVAL;
- }
-
if (!try_module_get(patch->mod)) {
mutex_unlock(&klp_mutex);
return -ENODEV;
@@ -1169,6 +1162,13 @@ int klp_enable_patch(struct klp_patch *patch)
klp_init_patch_early(patch);
+ if (!klp_is_patch_compatible(patch)) {
+ pr_err("Livepatch patch (%s) is not compatible with the already installed livepatches.\n",
+ patch->mod->name);
+ ret = -EINVAL;
+ goto err;
+ }
+
ret = klp_init_patch(patch);
if (ret)
goto err;
--
2.52.0