Thread (9 messages) 9 messages, 3 authors, 2019-05-24

Re: [PATCHv2] kernel/crash: make parse_crashkernel()'s return value more indicant

From: Pingfan Liu <hidden>
Date: 2019-05-02 06:22:20
Also in: linux-arm-kernel, linux-mips, linux-s390, linux-sh, lkml

On Thu, Apr 25, 2019 at 4:20 PM Pingfan Liu [off-list ref] wrote:
On Wed, Apr 24, 2019 at 4:31 PM Matthias Brugger [off-list ref] wrote:
quoted
[...]
quoted
quoted
@@ -139,6 +141,8 @@ static int __init parse_crashkernel_simple(char *cmdline,
              pr_warn("crashkernel: unrecognized char: %c\n", *cur);
              return -EINVAL;
      }
+     if (*crash_size == 0)
+             return -EINVAL;
This covers the case where I pass an argument like "crashkernel=0M" ?
Can't we fix that by using kstrtoull() in memparse and check if the return value
is < 0? In that case we could return without updating the retptr and we will be
fine.
After a series of work, I suddenly realized that it can not be done
like this way. "0M" causes kstrtoull() to return -EINVAL, but this is
caused by "M", not "0". If passing "0" to kstrtoull(), it will return
0 on success.
quoted
It seems that kstrtoull() treats 0M as invalid parameter, while
simple_strtoull() does not.
My careless going through the code. And I tested with a valid value
"256M" using kstrtoull(), it also returned -EINVAL.

So I think there is no way to distinguish 0 from a positive value
inside this basic math function.
Do I miss anything?

Thanks and regards,
Pingfan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help