Skip to content

Commit

Permalink
livepatch: Fix missing unlock on error in klp_enable_patch()
Browse files Browse the repository at this point in the history
Add missing unlock when try_module_get() fails in klp_enable_patch().

Fixes: 5ef3dd2 ("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
  • Loading branch information
Yang Yingliang authored and Petr Mladek committed Jan 4, 2022
1 parent 5ef3dd2 commit 50a0f3f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel/livepatch/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 50a0f3f

Please sign in to comment.