Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kexec -p fails on kernel versions of form x.y
@ 2013-07-25 22:21 Khalid Aziz
  2013-07-26  2:37 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Khalid Aziz @ 2013-07-25 22:21 UTC (permalink / raw)
  To: horms, ebiederman; +Cc: kexec, Khalid Aziz

"kexec -p" fails to load kernels with version of the form x.y instead of
x.y.z with an error message similar to "Unsupported utsname.release:
3.10-1-amd64". Code in kernel_version() also checks the wrong variable
name for error return value from strtoul() for "minor" and "patch", and
hence possibly missing a real error.

These changes fix both of these problems.

Signed-off-by: Khalid Aziz <khalid@gonehiking.org>
---
 kexec/kernel_version.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/kexec/kernel_version.c b/kexec/kernel_version.c
index 079312b..21fb13a 100644
--- a/kexec/kernel_version.c
+++ b/kexec/kernel_version.c
@@ -31,21 +31,20 @@ long kernel_version(void)
 	}
 
 	minor = strtoul(p, &p, 10);
-	if (major == ULONG_MAX) {
+	if (minor == ULONG_MAX) {
 		fprintf(stderr, "strtoul failed: %s\n", strerror(errno));
 		return -1;
 	}
 
-	if (*p++ != '.') {
-		fprintf(stderr, "Unsupported utsname.release: %s\n",
-			utsname.release);
-		return -1;
-	}
-
-	patch = strtoul(p, &p, 10);
-	if (major == ULONG_MAX) {
-		fprintf(stderr, "strtoul failed: %s\n", strerror(errno));
-		return -1;
+	/* There may or may not be a patch level for this kernel */
+	if (*p++ == '.') {
+		patch = strtoul(p, &p, 10);
+		if (patch == ULONG_MAX) {
+			fprintf(stderr, "strtoul failed: %s\n",strerror(errno));
+			return -1;
+		}
+	} else {
+		patch = 0;
 	}
 
 	if (major >= 256 || minor >= 256 || patch >= 256) {
-- 
1.8.3.2


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kexec -p fails on kernel versions of form x.y
  2013-07-25 22:21 [PATCH] kexec -p fails on kernel versions of form x.y Khalid Aziz
@ 2013-07-26  2:37 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2013-07-26  2:37 UTC (permalink / raw)
  To: Khalid Aziz; +Cc: kexec, ebiederman

On Thu, Jul 25, 2013 at 04:21:09PM -0600, Khalid Aziz wrote:
> "kexec -p" fails to load kernels with version of the form x.y instead of
> x.y.z with an error message similar to "Unsupported utsname.release:
> 3.10-1-amd64". Code in kernel_version() also checks the wrong variable
> name for error return value from strtoul() for "minor" and "patch", and
> hence possibly missing a real error.
> 
> These changes fix both of these problems.
> 
> Signed-off-by: Khalid Aziz <khalid@gonehiking.org>

Thanks, applied.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-26  2:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-25 22:21 [PATCH] kexec -p fails on kernel versions of form x.y Khalid Aziz
2013-07-26  2:37 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox