diff options
author | Petr Mladek <pmladek@suse.com> | 2017-10-20 10:56:51 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2017-10-26 08:58:50 -0400 |
commit | 89a9a1c1c89cea5f70975c338c011b9f7024dee5 (patch) | |
tree | 55d3fd12dba578268abe0b95e46db6f2d6e86034 /kernel/livepatch/core.c | |
parent | 5aaf1ab55389aeb6ce5527580a1a4d4dbc0f41ff (diff) |
livepatch: __klp_disable_patch() should never be called for disabled 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>
Diffstat (limited to 'kernel/livepatch/core.c')
-rw-r--r-- | kernel/livepatch/core.c | 5 |
1 files changed, 4 insertions, 1 deletions
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) | |||
282 | { | 282 | { |
283 | struct klp_object *obj; | 283 | struct klp_object *obj; |
284 | 284 | ||
285 | if (WARN_ON(!patch->enabled)) | ||
286 | return -EINVAL; | ||
287 | |||
285 | if (klp_transition_patch) | 288 | if (klp_transition_patch) |
286 | return -EBUSY; | 289 | return -EBUSY; |
287 | 290 | ||
@@ -293,7 +296,7 @@ static int __klp_disable_patch(struct klp_patch *patch) | |||
293 | klp_init_transition(patch, KLP_UNPATCHED); | 296 | klp_init_transition(patch, KLP_UNPATCHED); |
294 | 297 | ||
295 | klp_for_each_object(patch, obj) | 298 | klp_for_each_object(patch, obj) |
296 | if (patch->enabled && obj->patched) | 299 | if (obj->patched) |
297 | klp_pre_unpatch_callback(obj); | 300 | klp_pre_unpatch_callback(obj); |
298 | 301 | ||
299 | /* | 302 | /* |