Re: [patch 1/7] Extended crashkernel command line

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Bernhard Walle
Date: Wednesday, September 26, 2007 - 9:16 am

* Oleg Verych <olecom@flower.upol.cz> [2007-09-25 22:53]:

Ok, that's fixed now, see patch below.


I'm against guessing. The user has to specify a parameter which is
right according to syntax.

However, I plan to make a patch that the kernel can detect a sensible
offset automatically for i386 and x86_64 as it's done in ia64. Since
both architectures have a relocatable kernel now, that makes perfectly
sense. But that's another patch.

---

This patches improves error handling in parse_crashkernel_mem() by comparing
the return pointer of memparse() with the input pointer and also replaces
all printk(KERN_WARNING msg) with pr_warning(msg).


Signed-off-by: Bernhard Walle <bwalle@suse.de>

---
 kernel/kexec.c |   31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1172,33 +1172,50 @@ static int __init parse_crashkernel_mem(
 	do {
 		unsigned long long start = 0, end = ULLONG_MAX;
 		unsigned long long size = -1;
+		char *tmp;
 
 		/* get the start of the range */
-		start = memparse(cur, &cur);
+		start = memparse(cur, &tmp);
+		if (cur == tmp) {
+			pr_warning("crashkernel: Memory value expected\n");
+			return -EINVAL;
+		}
+		cur = tmp;
 		if (*cur != '-') {
-			printk(KERN_WARNING "crashkernel: '-' expected\n");
+			pr_warning("crashkernel: '-' expected\n");
 			return -EINVAL;
 		}
 		cur++;
 
 		/* if no ':' is here, than we read the end */
 		if (*cur != ':') {
-			end = memparse(cur, &cur);
+			end = memparse(cur, &tmp);
+			if (cur == tmp) {
+				pr_warning("crashkernel: Memory "
+						"value expected\n");
+				return -EINVAL;
+			}
+			cur = tmp;
 			if (end <= start) {
-				printk(KERN_WARNING "crashkernel: end <= start\n");
+				pr_warning("crashkernel: end <= start\n");
 				return -EINVAL;
 			}
 		}
 
 		if (*cur != ':') {
-			printk(KERN_WARNING "crashkernel: ':' expected\n");
+			pr_warning("crashkernel: ':' expected\n");
 			return -EINVAL;
 		}
 		cur++;
 
-		size = memparse(cur, &cur);
+		size = memparse(cur, &tmp);
+		if (cur == tmp) {
+			pr_warning("Memory value expected\n");
+			return -EINVAL;
+		}
+		cur = tmp;
 		if (size < 0) {
-			printk(KERN_WARNING "crashkernel: invalid size\n");
+			pr_warning("crashkernel: invalid size\n");
 			return -EINVAL;
 		}
 
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 1/7] Extended crashkernel command line, Bernhard Walle, (Tue Sep 25, 11:22 am)
Re: [patch 1/7] Extended crashkernel command line, Oleg Verych, (Tue Sep 25, 1:53 pm)
Re: [patch 1/7] Extended crashkernel command line, Bernhard Walle, (Wed Sep 26, 1:34 am)
Re: [patch 1/7] Extended crashkernel command line, Bernhard Walle, (Wed Sep 26, 9:16 am)
Re: [patch 1/7] Extended crashkernel command line, Oleg Verych, (Wed Sep 26, 11:18 am)
Re: [patch 1/7] Extended crashkernel command line, Bernhard Walle, (Wed Sep 26, 11:18 am)
Re: [patch 1/7] Extended crashkernel command line, Bernhard Walle, (Wed Sep 26, 2:05 pm)