The final step when loading livepatch module for livepatching a module is to actually enable the livepatch. The steps are exactly the same as in kmp_module_comming(). Note that there is no need to call klp_cleanup_module_patches_limited() in the error path. klp_add_object() modifies only the single matching struct klp_patch. Signed-off-by: Petr Mladek <pmladek@xxxxxxxx> --- kernel/livepatch/core.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 6c27b635e5a7..c21bd9ec2012 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1011,6 +1011,28 @@ int klp_add_object(struct klp_object *obj) goto err_free; } + pr_notice("applying patch '%s' to loading module '%s'\n", + patch->obj->patch_name, obj->name); + + ret = klp_pre_patch_callback(obj); + if (ret) { + pr_warn("pre-patch callback failed for object '%s'\n", + obj->name); + goto err_free; + } + + ret = klp_patch_object(obj); + if (ret) { + pr_warn("failed to apply patch '%s' to module '%s' (%d)\n", + patch->obj->patch_name, obj->name, ret); + + klp_post_unpatch_callback(obj); + goto err_free; + } + + if (patch != klp_transition_patch) + klp_post_patch_callback(obj); + mutex_unlock(&klp_mutex); return 0; -- 2.16.4