Commit 53910ef7 authored by Zhen Lei's avatar Zhen Lei Committed by Jiri Kosina
Browse files

livepatch: Move the result-invariant calculation out of the loop



The calculation results of the variables 'func_addr' and 'func_size' are
not affected by the for loop and do not change due to the changes of
entries[i]. The performance can be improved by moving it outside the loop.

No functional change.

Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 4de65c58
Loading
Loading
Loading
Loading
+27 −27
Original line number Diff line number Diff line
@@ -196,9 +196,6 @@ static int klp_check_stack_func(struct klp_func *func, unsigned long *entries,
	struct klp_ops *ops;
	int i;

	for (i = 0; i < nr_entries; i++) {
		address = entries[i];

	if (klp_target_state == KLP_UNPATCHED) {
		 /*
		  * Check for the to-be-unpatched function
@@ -227,6 +224,9 @@ static int klp_check_stack_func(struct klp_func *func, unsigned long *entries,
		}
	}

	for (i = 0; i < nr_entries; i++) {
		address = entries[i];

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