Skip to content

Commit

Permalink
livepatch: __klp_disable_patch() should never be called for disabled …
Browse files Browse the repository at this point in the history
…patches

__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>
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Petr Mladek authored and Jiri Kosina committed Oct 26, 2017
1 parent 5aaf1ab commit 89a9a1c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kernel/livepatch/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);

/*
Expand Down

0 comments on commit 89a9a1c

Please sign in to comment.