From: Yang Yingliang Date: Sat, 25 Dec 2021 02:51:15 +0000 (+0800) Subject: livepatch: Fix missing unlock on error in klp_enable_patch() X-Git-Tag: v6.1-rc5~2208^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50a0f3f55e382b313e7cbebdf8ccf1593296e16f;p=platform%2Fkernel%2Flinux-starfive.git livepatch: Fix missing unlock on error in klp_enable_patch() 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 Signed-off-by: Yang Yingliang Acked-by: David Vernet Reviewed-by: Petr Mladek Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20211225025115.475348-1-yangyingliang@huawei.com --- diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 7d228cd..585494e 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1047,8 +1047,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);