lkml.org 
[lkml]   [2017]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] livepatch: __klp_disable_patch() should never be called for disabled patches
On Fri, 20 Oct 2017, Petr Mladek wrote:

> __klp_disable_patch() should never be called when the patch is not
> enabled. Let's add the same warning that we have in __klp_enable_patch().
>
> This allows to remove the check when calling klp_pre_unpatch_callback().
> It was strange anyway because it repeatedly checked per-patch flag
> for each patched object.
>
> Signed-off-by: Petr Mladek <pmladek@suse.com>

Heh, this is not a new thing. See
http://lkml.kernel.org/r/20141128170735.GD32376@dhcp128.suse.cz

I don't know why it got lost. Those were crazy times...

Miroslav

> ---
> kernel/livepatch/core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> index eb134479c394..287f71e9dbfe 100644
> --- a/kernel/livepatch/core.c
> +++ b/kernel/livepatch/core.c
> @@ -282,6 +282,9 @@ static int __klp_disable_patch(struct klp_patch *patch)
> {
> struct klp_object *obj;
>
> + if (WARN_ON(!patch->enabled))
> + return -EINVAL;
> +
> if (klp_transition_patch)
> return -EBUSY;
>
> @@ -293,7 +296,7 @@ static int __klp_disable_patch(struct klp_patch *patch)
> klp_init_transition(patch, KLP_UNPATCHED);
>
> klp_for_each_object(patch, obj)
> - if (patch->enabled && obj->patched)
> + if (obj->patched)
> klp_pre_unpatch_callback(obj);
>
> /*
> --
> 1.8.5.6
>

\
 
 \ /
  Last update: 2017-11-01 11:11    [W:2.874 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site