livepatch: Fix missing unlock on error in klp_enable_patch()
PATCH 1/1 livepatch: Fix missing unlock on error in klp_enable_patch()
Add missing unlock when try_module_get() fails in klp_enable_patch().
--- kernel/livepatch/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/livepatch/core.c +3 -1
@@ -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);
Signature · 1 line
2.25.1
Yang Yingliang <[email protected]> wrote on Sat [2021-Dec-25 10:51:15 +0800]:
Quoted 28 lines
Add missing unlock when
try_module_get()fails inklp_enable_patch().Fixes bf01c2975925 ("livepatch: Fix kobject refcount bug on klp_init_patch_early failure path")Reported-by Hulk Robot <[email protected]>Signed-off-by Yang Yingliang <[email protected]>--- kernel/livepatch/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)kernel/livepatch/core.c +3
-1@@ -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);Signature · 1 line
2.25.1
Apologies for the silly oversight. Thank you for the fix.
Quoted 24 lines · David Vernet
Yang Yingliang <[email protected]> wrote on Sat [2021-Dec-25 10:51:15 +0800]:
Quoted 23 lines
Add missing unlock when
try_module_get()fails inklp_enable_patch().Fixes bf01c2975925 ("livepatch: Fix kobject refcount bug on klp_init_patch_early failure path")Reported-by Hulk Robot <[email protected]>Signed-off-by Yang Yingliang <[email protected]>--- kernel/livepatch/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)kernel/livepatch/core.c +3
-1@@ -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 ; + }
Quoted 7 lines
Quoted 5 lines
kernel/livepatch/core.c +0
-0klp_init_patch_early (patch);Signature · 1 line
2.25.1Apologies for the silly oversight. Thank you for the fix.
And nobody caught it. I think that it was partly caused by a pre-holiday loss of concentration :-/
Quoted 1 line
Acked-by David Vernet <[email protected]>
Best Regards,
Petr
Petr Mladek
maintainerQuoted 5 lines · Yang Yingliang
Add missing unlock when
try_module_get()fails inklp_enable_patch().Fixes bf01c2975925 ("livepatch: Fix kobject refcount bug on klp_init_patch_early failure path")Reported-by Hulk Robot <[email protected]>Signed-off-by Yang Yingliang <[email protected]>
JFYI, the patch has been committed into livepatch.git, branch for-5.17/fixes.
Best Regards,
Petr
Petr Mladek
maintainerQuoted 9 lines · Petr Mladek
Quoted 5 lines · Yang Yingliang
Add missing unlock when
try_module_get()fails inklp_enable_patch().Fixes bf01c2975925 ("livepatch: Fix kobject refcount bug on klp_init_patch_early failure path")Reported-by Hulk Robot <[email protected]>Signed-off-by Yang Yingliang <[email protected]>JFYI, the patch has been committed into livepatch.git, branch for-5.17/fixes.
Just for record. I had to rebase the branch for-5.17/fixes because of missing Signed-off. I have updated Fixes: line to match the hash of the rebased commit. I hope that this fixed all my pre-holidays mistakes.
Best Regards,
Petr