Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp590898pxp; Sat, 19 Mar 2022 10:47:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMOn0QMxf5m9sm82hUQdzC1vAoViZE1FEgF0zf5MBQG/puvTtXye+wDrpkc0wAhdaSe5I8 X-Received: by 2002:a05:6402:280a:b0:418:63df:4af9 with SMTP id h10-20020a056402280a00b0041863df4af9mr15581489ede.84.1647712074094; Sat, 19 Mar 2022 10:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647712074; cv=none; d=google.com; s=arc-20160816; b=JBySEGYA/HNadicr5ZI2ycyrmNyCKC0XawpE6mI8jZemVQYBRiyvOyQa41xHZuPGY3 sAv2uM5Q3eUZIGk3SNFQ0x0pzfAyzw3f3QbSe3iFB+xID7UG47LHkRBOBHKs/Zffjka7 zZyf5rh2T9N47CkUtcdavN45j0IJak9DsDs4e+ITvldbMQHzUVbfbZFi8m8ZNfr2m2je vfjB04zvm2P6H6LfJ0HnqrQWln8opDcj3HKtX6SpYUC/KwN2MI7P87z0czt2FmpoPHfv VwJAcYX2ulPdUouEoDn7cT9PX5tpBbpgTyek/kE4ugJC07WAns/Ogb9FstCNx9cdxfiR 8WLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=fIG7D4UpjV3GMy0vqWWO8JhAHPMoHGcCoB7CKjr45vA=; b=n4QokL4n1qTSwcIXxb3gbh2XCE6r0VetT1kBvHz1bB1Aknx1K47/xvgtZSjwnvUCje PSgwOopqF/HO7QnZqLYSiAEnG3GLoJ6YISoLLrWqhxBKtlSCiYJxV+txRdYoxHAy7zGV oRBTDINyz4V8XnBbq7G6INQ8pehJycgeM4JKZY7IQR9GzjPxsZjqeDCmGiLasH95UxXt yW/cXP4p5rfdjoMFDb73hJRzE3Q1Fiz+GBxD2MOjYZBooKO5MDvgiqTzYT0IMCTTsaAl kGVR/LY7CtRKW5IykobVlDi43sUQzY8HJhWUIGXzJheGkucGwUxi4M6OBVYvncFLvvmi ztMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a170906b18400b006df87e44b22si3545644ejy.973.2022.03.19.10.47.29; Sat, 19 Mar 2022 10:47:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237719AbiCRPGo (ORCPT + 99 others); Fri, 18 Mar 2022 11:06:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237221AbiCRPGn (ORCPT ); Fri, 18 Mar 2022 11:06:43 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E55BD1C906; Fri, 18 Mar 2022 08:05:23 -0700 (PDT) Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxqsywnzRicaQLAA--.9144S3; Fri, 18 Mar 2022 23:05:21 +0800 (CST) From: Tiezhu Yang To: Thomas Bogendoerfer Cc: Xuefeng Li , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] MIPS: Return -EINVAL if mem parameter is empty in early_parse_mem() Date: Fri, 18 Mar 2022 23:05:18 +0800 Message-Id: <1647615920-23103-2-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1647615920-23103-1-git-send-email-yangtiezhu@loongson.cn> References: <1647615920-23103-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9AxqsywnzRicaQLAA--.9144S3 X-Coremail-Antispam: 1UD129KBjvdXoW7XF1kJw1fWw4rWr17ZFWxtFb_yoWfGrgEkr ZIqw1kGr1rJF1aqrZFqayfXFyaqay7ur1ruwsxWrWakr98Xr1UJFZ5AF9xXrn5Xr4q9rs5 trZ8WFn29w1xujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbSxFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGwA2048vs2IY02 0Ec7CjxVAFwI0_Jrv_JF4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWUCVW8JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E 0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67 AKxVWUJVWUGwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48I cxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_XrWl42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfU1OzsUUUUU X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the current code, the users usually need to make sure the value of mem parameter is correct, but it is better to do some check to avoid potential boot hangs. This commit checks whether mem parameter is empty, if yes, return -EINVAL before call memblock_remove() and memblock_add(). Signed-off-by: Tiezhu Yang --- arch/mips/kernel/setup.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index f979adf..14aa8bd 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -344,6 +344,11 @@ static int __init early_parse_mem(char *p) { phys_addr_t start, size; + if (!p) { + pr_err("mem parameter is empty, do nothing\n"); + return -EINVAL; + } + /* * If a user specifies memory size, we * blow away any automatically generated -- 2.1.0