Skip to content

Commit 89a9a1c

Browse files
pmladekJiri Kosina
authored andcommitted
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 <[email protected]> Acked-by: Joe Lawrence <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 5aaf1ab commit 89a9a1c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kernel/livepatch/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ static int __klp_disable_patch(struct klp_patch *patch)
282282
{
283283
struct klp_object *obj;
284284

285+
if (WARN_ON(!patch->enabled))
286+
return -EINVAL;
287+
285288
if (klp_transition_patch)
286289
return -EBUSY;
287290

@@ -293,7 +296,7 @@ static int __klp_disable_patch(struct klp_patch *patch)
293296
klp_init_transition(patch, KLP_UNPATCHED);
294297

295298
klp_for_each_object(patch, obj)
296-
if (patch->enabled && obj->patched)
299+
if (obj->patched)
297300
klp_pre_unpatch_callback(obj);
298301

299302
/*

0 commit comments

Comments
 (0)