
From: Ye Weihua <yeweihua4@huawei.com> hulk inclusion category: bugfix bugzilla: 176976 https://gitee.com/openeuler/kernel/issues/I4DDEL -------------------------------- Before enable a livepatch, we apply for a piece of memory for func_node to store function information and release it after disable this livepatch. However, in some special cases, for example, the livepatch code is running, disable fails. In these cases, the applied memory should not be released. Otherwise, the livepatch cannot be disabled. So, we move arch_klp_mem_recycle after the return value judgment to solve this problem. Fixes: ec7ce700674f ("livepatch: put memory alloc and free out stop machine") Signed-off-by: Ye Weihua <yeweihua4@huawei.com> Reviewed-by: Yang Jihong <yangjihong1@huawei.com> Signed-off-by: Chen Jun <chenjun102@huawei.com> --- kernel/livepatch/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 58cdfeea46d2..7cea023e88f4 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1323,11 +1323,11 @@ static int __klp_disable_patch(struct klp_patch *patch) arch_klp_code_modify_prepare(); ret = stop_machine(klp_try_disable_patch, &patch_data, cpu_online_mask); - arch_klp_mem_recycle(patch); arch_klp_code_modify_post_process(); if (ret) return ret; + arch_klp_mem_recycle(patch); klp_free_patch_async(patch); return 0; } -- 2.20.1