From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C4FDC43219 for ; Sun, 28 Apr 2019 08:39:11 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E1D8214AF for ; Sun, 28 Apr 2019 08:39:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E1D8214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44sLmm37t3zDqcy for ; Sun, 28 Apr 2019 18:39:04 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=redhat.com (client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=dyoung@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44sLlG0jcCzDqB0 for ; Sun, 28 Apr 2019 18:37:41 +1000 (AEST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BEE19308425B; Sun, 28 Apr 2019 08:37:36 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-104.pek2.redhat.com [10.72.12.104]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF1721001DCE; Sun, 28 Apr 2019 08:37:14 +0000 (UTC) Date: Sun, 28 Apr 2019 16:37:10 +0800 From: Dave Young To: Pingfan Liu Subject: Re: [PATCHv2] kernel/crash: make parse_crashkernel()'s return value more indicant Message-ID: <20190428083710.GA11981@dhcp-128-65.nay.redhat.com> References: <1556087581-14513-1-git-send-email-kernelfans@gmail.com> <10dc5468-6cd9-85c7-ba66-1dfa5aa922b7@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Sun, 28 Apr 2019 08:37:38 +0000 (UTC) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rich Felker , linux-ia64@vger.kernel.org, Julien Thierry , Yangtao Li , Palmer Dabbelt , Heiko Carstens , Stefan Agner , linux-mips@vger.kernel.org, Paul Mackerras , "H. Peter Anvin" , Thomas Gleixner , Logan Gunthorpe , linux-s390@vger.kernel.org, Florian Fainelli , Yoshinori Sato , linux-sh@vger.kernel.org, x86@kernel.org, Russell King , Ingo Molnar , Hari Bathini , Catalin Marinas , James Hogan , Fenghua Yu , Tony Luck , Will Deacon , Johannes Weiner , Borislav Petkov , David Hildenbrand , linux-arm-kernel@lists.infradead.org, Jens Axboe , Matthias Brugger , Baoquan He , Ard Biesheuvel , Robin Murphy , kexec@lists.infradead.org, LKML , Ralf Baechle , Thomas Bogendoerfer , Paul Burton , Greg Kroah-Hartman , Martin Schwidefsky , Andrew Morton , linuxppc-dev@lists.ozlabs.org, Greg Hackmann Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 04/25/19 at 04:20pm, Pingfan Liu wrote: > On Wed, Apr 24, 2019 at 4:31 PM Matthias Brugger 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. > > > It seems that kstrtoull() treats 0M as invalid parameter, while > simple_strtoull() does not. > > If changed like your suggestion, then all the callers of memparse() > will treats 0M as invalid parameter. This affects many components > besides kexec. Not sure this can be done or not. simple_strtoull is obsolete, move to kstrtoull is the right way. $ git grep memparse|wc 158 950 10479 Except some documentation/tools etc there are still a log of callers which directly use the return value as the ull number without error checking. So it would be good to mark memparse as obsolete as well in lib/cmdline.c, and introduce a new function eg. kmemparse() to use kstrtoull, and return a real error code, and save the size in an argument like &size. Then update X86 crashkernel code to use it. Thanks Dave