[PATCH] kexec-tools: fix failure when kernel version patchlevel >255
Joe Korty
joe.korty at concurrent-rt.com
Fri Apr 9 16:46:42 BST 2021
[PATCH] kexec-tools: fix kexec failure when kernel version patchlevel >255
[ 2nd try, to a larger cc: list, and this time submitted
with a patch rather than just a bug report ]
Kexec blows up when the kernel version patchlevel is >255.
This was first noticed when a 4.4.262 kernel was booted
on a CentOS 7 system. The message on the console is of
the form:
Unsupported utsname.release: 4.4.262
The attached patch should fix this. Untested. There might
be a few places where a hardcoded constant rather than
KERNEL_VERSION is used, but I did not see any.
Signed-off-by: Joe Korty <joe.korty at concurrent-rt.com
diff --git a/kexec/kernel_version.c b/kexec/kernel_version.c
index 21fb13adf095..36c06ffd603d 100644
--- a/kexec/kernel_version.c
+++ b/kexec/kernel_version.c
@@ -47,7 +47,7 @@ long kernel_version(void)
patch = 0;
}
- if (major >= 256 || minor >= 256 || patch >= 256) {
+ if (major >= 256 || minor >= 256 || patch >= 65536) {
fprintf(stderr, "Unsupported utsname.release: %s\n",
utsname.release);
return -1;
diff --git a/kexec/kexec.h b/kexec/kexec.h
index f0f347d5e9e0..b388475ffa5a 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -180,7 +180,7 @@ extern const struct arch_map_entry arches[];
long physical_arch(void);
#define KERNEL_VERSION(major, minor, patch) \
- (((major) << 16) | ((minor) << 8) | patch)
+ (((major) << 24) | ((minor) << 16) | patch)
long kernel_version(void);
void usage(void);
More information about the kexec
mailing list