Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2561953ybm; Thu, 23 May 2019 20:14:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0oRJ9soODT4UJyDFAtNHtRmUdYMnsZwaq1ReitN/uUOVTwV5tm/Bve9vy/HauwNnzEVbS X-Received: by 2002:a63:1a03:: with SMTP id a3mr103862947pga.412.1558667670390; Thu, 23 May 2019 20:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558667670; cv=none; d=google.com; s=arc-20160816; b=UYMqqFpbtX806ITxwVBY0V310NnSkvXvDEEJOVKF8kJMkefo1HKRSF2OI7x6As2fj5 Zz61oTjsmXKcMo41eqstIYVtC4D2WqZmGpWIBFZhK8wwNDvZSwAL5JQI51sJv3/GdcaP B0rTjhkzRsoBnB7/ND1MNV31Rm58MzR9cYj5rDkq87ZfKhqcdsxfPyI44mSM2VwnOW90 a3hHXqymsq2CAHucWjc212b6sJINTmwbUHz1gYSmZVHeOIkeNNMsP1/1AGoXsMOxWNwO GxlNZllKUzuRMsvE3BIP8zjYRfvyMVzS+dgdytVEuwP16oZLs39h4oLf2pEDUeilDXba 6BYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=E7hznSwoqjG8X1odMBGc2satoFe87v1Y0P/9fKHS9SY=; b=E7ka8UKnZYGegrMwsyXlGuAJjghAULEqIYvUr41DREhCK227mOiocSDZTTQlE9EOW4 WK7dDIkQAYwJC2FedNMJG0s4t+yMBlRp8cDF97nl3TKQ2ZcuO0kUJvvciAbIVcF1NwZu p99sZ6K9FvePmE+TjUUmyfQB7VnEp6viSURm3lwVn+YpMd4F4taF8752uGe51s7a7/uq GUrtVFyztT8fVMty8oGiz7kXJHrS+UT1WPpGAPAAHx5J+JapOW0TG/pr1nz7XcGFc5qd Y8XGMEHjRzRTbdJlbIcece38CcIVp8QT6sx+i0DVSGJTO296niRwRA6rJP82pCuW1Z6F YyDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a7Sc0Zml; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k17si2462884pfd.278.2019.05.23.20.14.11; Thu, 23 May 2019 20:14:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a7Sc0Zml; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388429AbfEXDL1 (ORCPT + 99 others); Thu, 23 May 2019 23:11:27 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:39143 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387559AbfEXDL1 (ORCPT ); Thu, 23 May 2019 23:11:27 -0400 Received: by mail-it1-f194.google.com with SMTP id 9so11694522itf.4; Thu, 23 May 2019 20:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E7hznSwoqjG8X1odMBGc2satoFe87v1Y0P/9fKHS9SY=; b=a7Sc0ZmlEG6jC7OpcrRVUkNXq0SBb3Dc/hNdk5Vi6ayUDLd0Dm8M0wWvJFgwttZZ4M aninTKfSUZDRjfNGqPsMzWLja++EezX/hO4fX5nJBzfyFI6kNO7dvjypaoVQz4ys7+R5 9IVPBxW1C4i6BRZ4f3bqLocvJh1c9QUTPILj4gipCVXMgVTUpT9LBYkMiRDL2TaalXNe rQ6wJugIty6JwVWYs5nF97JpvrTENcxT3PWNqVTqRhEna4JwxQokvn2SUzkeP09LHMDC DgccA6RcG2CmDNt2DoIHjZymnDK30hw9WxWvnBoApiNxfRbL6LLAu65RJr1Ih71O/P5e SodQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E7hznSwoqjG8X1odMBGc2satoFe87v1Y0P/9fKHS9SY=; b=Ezz2Tgeoxjdv/gvVJ/MA5BphhJp0ROY7eGuEAPB34pjOfZ9Qhjq2ttOZI492SrJqID oYb+trVWohcEsTTnuvrXvqhM9++ob+KDmqye9lu5WGczS9UEq2zlUGooX0bFUTQ7eDNO 73TpY8KHHy+M7pkUnZ7s50p4JClZ/FVH+/BnIUFnJHG2PFE26yzI5AaPHTyZc6iITSaB nqFqf1RuwcGj8pV4vQ7v0OO0m5cntojFaB/EJT2diuKOwc2KO87DKUsVqyDu/xj3efNO jRbywuuPXIY3ktLzuRoSCd49qjhz+CSclAPfHslijAnC/ldpKQ38cq/SakMisXgIe5f4 /CnQ== X-Gm-Message-State: APjAAAU/nXJChSYn3/OkCY5jM66bpCt/c1PazWN/OjkBlJQ/qjpoKeug A1Ap6yIXeByCvDlPB2sRDwiDyk7343xDzT5OICXlSzV8sA== X-Received: by 2002:a24:1dce:: with SMTP id 197mr16766439itj.16.1558667486023; Thu, 23 May 2019 20:11:26 -0700 (PDT) MIME-Version: 1.0 References: <1556087581-14513-1-git-send-email-kernelfans@gmail.com> <10dc5468-6cd9-85c7-ba66-1dfa5aa922b7@suse.com> In-Reply-To: From: Pingfan Liu Date: Fri, 24 May 2019 11:11:13 +0800 Message-ID: Subject: Re: [PATCHv2] kernel/crash: make parse_crashkernel()'s return value more indicant To: Matthias Brugger Cc: LKML , Rich Felker , linux-ia64@vger.kernel.org, Julien Thierry , Yangtao Li , Benjamin Herrenschmidt , Palmer Dabbelt , Heiko Carstens , x86@kernel.org, linux-mips@vger.kernel.org, Paul Mackerras , "H. Peter Anvin" , linux-s390@vger.kernel.org, Florian Fainelli , Yoshinori Sato , linux-sh@vger.kernel.org, Michael Ellerman , David Hildenbrand , Russell King , Ingo Molnar , linux-arm-kernel@lists.infradead.org, Catalin Marinas , James Hogan , Dave Young , Fenghua Yu , Will Deacon , linuxppc-dev@lists.ozlabs.org, Ananth N Mavinakayanahalli , Borislav Petkov , Stefan Agner , Thomas Gleixner , Hari Bathini , Jens Axboe , Tony Luck , Baoquan He , Ard Biesheuvel , Robin Murphy , Greg Kroah-Hartman , Ralf Baechle , Thomas Bogendoerfer , Paul Burton , Johannes Weiner , Martin Schwidefsky , Andrew Morton , Logan Gunthorpe , Greg Hackmann Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Matthias, ping? Any suggestions? Thanks, Pingfan On Thu, May 2, 2019 at 2:22 PM Pingfan Liu wrote: > > On Thu, Apr 25, 2019 at 4:20 PM 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. > 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