livepatch: Improve error handling in klp_disable_func()
authorMinfei Huang <mnfhuang@gmail.com>
Tue, 14 Jul 2015 03:15:37 +0000 (11:15 +0800)
committerJiri Kosina <jkosina@suse.com>
Tue, 14 Jul 2015 20:48:06 +0000 (22:48 +0200)
In case of func->state or func->old_addr not having expected values,
we'd rather bail out immediately from klp_disable_func().

This can't really happen with the current codebase, but fix this
anyway in the sake of robustness.

[jkosina@suse.com: reworded the changelog a bit]
Signed-off-by: Minfei Huang <mnfhuang@gmail.com>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
kernel/livepatch/core.c

index c40ebcca0495fc5fb003e44c4c6549bc39fcd08d..6e5344112419ca43ace3474466db35d1692752ab 100644 (file)
@@ -348,8 +348,10 @@ static void klp_disable_func(struct klp_func *func)
 {
        struct klp_ops *ops;
 
-       WARN_ON(func->state != KLP_ENABLED);
-       WARN_ON(!func->old_addr);
+       if (WARN_ON(func->state != KLP_ENABLED))
+               return;
+       if (WARN_ON(!func->old_addr))
+               return;
 
        ops = klp_find_ops(func->old_addr);
        if (WARN_ON(!ops))