From: Zheng Yejian zhengyejian1@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4SFHQ
--------------------------------
Refer to following function procedure, klp_free_objects_mod_limited seems redundant, so remove it: klp_register_patch klp_init_patch klp_init_object <--- klp_find_object_module \ try_module_get |<-- 1. If something wrong here jump_label_register <---- klp_free_objects_mod_limited <-- 2. Check and put 'obj->mod' module_put klp_free_patch_start <-- 3. Check and put 'obj->mod' again klp_free_objects __klp_free_objects module_put
Signed-off-by: Zheng Yejian zhengyejian1@huawei.com Reviewed-by: Xu Kuohai xukuohai@huawei.com Reviewed-by: Cheng Jian cj.chengjian@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- kernel/livepatch/core.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-)
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index e964d834203a..c9c76b440177 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1185,23 +1185,6 @@ static int klp_init_patch_early(struct klp_patch *patch) return 0; }
-#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY -static void klp_free_objects_mod_limited(struct klp_patch *patch, - struct klp_object *limit) -{ - struct klp_object *obj, *tmp_obj; - - klp_for_each_object_safe(patch, obj, tmp_obj) { - if (limit == obj) - break; - if (klp_is_module(obj) && obj->mod) { - module_put(obj->mod); - obj->mod = NULL; - } - } -} -#endif - static int klp_init_patch(struct klp_patch *patch) { struct klp_object *obj; @@ -1220,7 +1203,7 @@ static int klp_init_patch(struct klp_patch *patch) klp_for_each_object(patch, obj) { ret = klp_init_object(patch, obj); if (ret) - goto out; + return ret; }
flush_module_icache(patch->mod); @@ -1230,7 +1213,7 @@ static int klp_init_patch(struct klp_patch *patch) ret = jump_label_register(patch->mod); if (ret) { module_enable_ro(patch->mod, true); - goto out; + return ret; } module_enable_ro(patch->mod, true);
@@ -1242,11 +1225,6 @@ static int klp_init_patch(struct klp_patch *patch) list_add_tail(&patch->list, &klp_patches);
return 0; -out: -#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY - klp_free_objects_mod_limited(patch, obj); -#endif - return ret; }
#ifdef CONFIG_LIVEPATCH_PER_TASK_CONSISTENCY