Commit 70e6a87c authored by Zheng Yejian's avatar Zheng Yejian Committed by Zheng Zengkai
Browse files

livepatch/core: Remove redundant klp_free_objects_mod_limited

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: default avatarZheng Yejian <zhengyejian1@huawei.com>
Reviewed-by: default avatarXu Kuohai <xukuohai@huawei.com>
Reviewed-by: default avatarCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent a891dbbe
Loading
Loading
Loading
Loading
+2 −24
Original line number Original line Diff line number Diff line
@@ -1185,23 +1185,6 @@ static int klp_init_patch_early(struct klp_patch *patch)
	return 0;
	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)
static int klp_init_patch(struct klp_patch *patch)
{
{
	struct klp_object *obj;
	struct klp_object *obj;
@@ -1220,7 +1203,7 @@ static int klp_init_patch(struct klp_patch *patch)
	klp_for_each_object(patch, obj) {
	klp_for_each_object(patch, obj) {
		ret = klp_init_object(patch, obj);
		ret = klp_init_object(patch, obj);
		if (ret)
		if (ret)
			goto out;
			return ret;
	}
	}


	flush_module_icache(patch->mod);
	flush_module_icache(patch->mod);
@@ -1230,7 +1213,7 @@ static int klp_init_patch(struct klp_patch *patch)
	ret = jump_label_register(patch->mod);
	ret = jump_label_register(patch->mod);
	if (ret) {
	if (ret) {
		module_enable_ro(patch->mod, true);
		module_enable_ro(patch->mod, true);
		goto out;
		return ret;
	}
	}
	module_enable_ro(patch->mod, true);
	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);
	list_add_tail(&patch->list, &klp_patches);


	return 0;
	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
#ifdef CONFIG_LIVEPATCH_PER_TASK_CONSISTENCY