Skip to content

Commit e1a1cce

Browse files
committed
Merge tag 'livepatching-for-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching
Pull livepatching update from Petr Mladek: - code cleanup * tag 'livepatching-for-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching: livepatch: Move the result-invariant calculation out of the loop
2 parents a312a8c + 53910ef commit e1a1cce

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

kernel/livepatch/transition.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -196,36 +196,36 @@ static int klp_check_stack_func(struct klp_func *func, unsigned long *entries,
196196
struct klp_ops *ops;
197197
int i;
198198

199-
for (i = 0; i < nr_entries; i++) {
200-
address = entries[i];
199+
if (klp_target_state == KLP_UNPATCHED) {
200+
/*
201+
* Check for the to-be-unpatched function
202+
* (the func itself).
203+
*/
204+
func_addr = (unsigned long)func->new_func;
205+
func_size = func->new_size;
206+
} else {
207+
/*
208+
* Check for the to-be-patched function
209+
* (the previous func).
210+
*/
211+
ops = klp_find_ops(func->old_func);
201212

202-
if (klp_target_state == KLP_UNPATCHED) {
203-
/*
204-
* Check for the to-be-unpatched function
205-
* (the func itself).
206-
*/
207-
func_addr = (unsigned long)func->new_func;
208-
func_size = func->new_size;
213+
if (list_is_singular(&ops->func_stack)) {
214+
/* original function */
215+
func_addr = (unsigned long)func->old_func;
216+
func_size = func->old_size;
209217
} else {
210-
/*
211-
* Check for the to-be-patched function
212-
* (the previous func).
213-
*/
214-
ops = klp_find_ops(func->old_func);
215-
216-
if (list_is_singular(&ops->func_stack)) {
217-
/* original function */
218-
func_addr = (unsigned long)func->old_func;
219-
func_size = func->old_size;
220-
} else {
221-
/* previously patched function */
222-
struct klp_func *prev;
223-
224-
prev = list_next_entry(func, stack_node);
225-
func_addr = (unsigned long)prev->new_func;
226-
func_size = prev->new_size;
227-
}
218+
/* previously patched function */
219+
struct klp_func *prev;
220+
221+
prev = list_next_entry(func, stack_node);
222+
func_addr = (unsigned long)prev->new_func;
223+
func_size = prev->new_size;
228224
}
225+
}
226+
227+
for (i = 0; i < nr_entries; i++) {
228+
address = entries[i];
229229

230230
if (address >= func_addr && address < func_addr + func_size)
231231
return -EAGAIN;

0 commit comments

Comments
 (0)