Re: [PATCHv2] kernel/crash: make parse_crashkernel()'s return value more indicant
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Matthias Brugger <mbrugger@xxxxxxxx>
- Subject: Re: [PATCHv2] kernel/crash: make parse_crashkernel()'s return value more indicant
- From: Pingfan Liu <kernelfans@xxxxxxxxx>
- Date: Thu, 2 May 2019 14:22:06 +0800
- Cc: LKML <linux-kernel@xxxxxxxxxxxxxxx>, Rich Felker <dalias@xxxxxxxx>, linux-ia64@xxxxxxxxxxxxxxx, Julien Thierry <julien.thierry@xxxxxxx>, Yangtao Li <tiny.windzz@xxxxxxxxx>, Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxx>, Heiko Carstens <heiko.carstens@xxxxxxxxxx>, x86@xxxxxxxxxx, linux-mips@xxxxxxxxxxxxxxx, Paul Mackerras <paulus@xxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, linux-s390@xxxxxxxxxxxxxxx, Florian Fainelli <f.fainelli@xxxxxxxxx>, Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>, linux-sh@xxxxxxxxxxxxxxx, Michael Ellerman <mpe@xxxxxxxxxxxxxx>, David Hildenbrand <david@xxxxxxxxxx>, Russell King <linux@xxxxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, Catalin Marinas <catalin.marinas@xxxxxxx>, James Hogan <jhogan@xxxxxxxxxx>, Dave Young <dyoung@xxxxxxxxxx>, Fenghua Yu <fenghua.yu@xxxxxxxxx>, Will Deacon <will.deacon@xxxxxxx>, linuxppc-dev@xxxxxxxxxxxxxxxx, Ananth N Mavinakayanahalli <ananth@xxxxxxxxxxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Stefan Agner <stefan@xxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Hari Bathini <hbathini@xxxxxxxxxxxxx>, Jens Axboe <axboe@xxxxxxxxx>, Tony Luck <tony.luck@xxxxxxxxx>, Baoquan He <bhe@xxxxxxxxxx>, Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx>, Robin Murphy <robin.murphy@xxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Ralf Baechle <ralf@xxxxxxxxxxxxxx>, Thomas Bogendoerfer <tbogendoerfer@xxxxxxx>, Paul Burton <paul.burton@xxxxxxxx>, Johannes Weiner <hannes@xxxxxxxxxxx>, Martin Schwidefsky <schwidefsky@xxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Logan Gunthorpe <logang@xxxxxxxxxxxx>, Greg Hackmann <ghackmann@xxxxxxxxxxx>
- In-reply-to: <CAFgQCTstd667wP6g+maxYekz4u3iBR2R=FHUiS1V=XxTs6MKUw@mail.gmail.com>
- References: <1556087581-14513-1-git-send-email-kernelfans@gmail.com> <10dc5468-6cd9-85c7-ba66-1dfa5aa922b7@suse.com> <CAFgQCTstd667wP6g+maxYekz4u3iBR2R=FHUiS1V=XxTs6MKUw@mail.gmail.com>
On Thu, Apr 25, 2019 at 4:20 PM Pingfan Liu <kernelfans@xxxxxxxxx> wrote:
>
> On Wed, Apr 24, 2019 at 4:31 PM Matthias Brugger <mbrugger@xxxxxxxx> wrote:
> >
> >
> [...]
> > > @@ -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.
> >
> 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
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]