From b5f77d06084aed886ee4e9eaad8729f67e95b933 Mon Sep 17 00:00:00 2001 From: Juerg Haefliger Date: Thu, 9 Nov 2017 14:02:55 +0100 Subject: [PATCH] kpatch-build: Stop reading vmlinux after the first match When searching for 'Linux version ...' in vmlinux, stop after the first match so that we don't keep reading a potentially huge file. Signed-off-by: Juerg Haefliger --- kpatch-build/kpatch-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index 297c4ae..dec75ed 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -481,7 +481,7 @@ if [[ -n "$USERSRCDIR" ]]; then [[ ! -e "$VMLINUX" ]] && die "can't find vmlinux" # Extract the target kernel version from vmlinux in this case. - ARCHVERSION="$(strings "$VMLINUX" | grep -e "^Linux version" | awk '{ print($3); }')" + ARCHVERSION="$(strings "$VMLINUX" | grep -m 1 -e "^Linux version" | awk '{ print($3); }')" fi [[ -z "$ARCHVERSION" ]] && ARCHVERSION="$(uname -r)"