From: Yang Yingliang yangyingliang@huawei.com
mainline inclusion from mainline-v5.17-rc1 commit 50a0f3f55e382b313e7cbebdf8ccf1593296e16f category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4TF7T Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
--------------------------------
Add missing unlock when try_module_get() fails in klp_enable_patch().
Fixes: 5ef3dd20555e8e8 ("livepatch: Fix kobject refcount bug on klp_init_patch_early failure path") Reported-by: Hulk Robot hulkci@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com Acked-by: David Vernet void@manifault.com Reviewed-by: Petr Mladek pmladek@suse.com Signed-off-by: Petr Mladek pmladek@suse.com Link: https://lore.kernel.org/r/20211225025115.475348-1-yangyingliang@huawei.com Signed-off-by: Zheng Yejian zhengyejian1@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- kernel/livepatch/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index b0f54d4c663b..660a4b4f61e4 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1447,8 +1447,10 @@ int klp_enable_patch(struct klp_patch *patch) return -EINVAL; }
- if (!try_module_get(patch->mod)) + if (!try_module_get(patch->mod)) { + mutex_unlock(&klp_mutex); return -ENODEV; + }
klp_init_patch_early(patch);