Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp731829rwd; Sat, 27 May 2023 05:45:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5llyorb7iAYA/X1SrAic+U7XmM5cyjUd/q4+tapHtIgsFT+TENh1ildtvGlcIg5bVm+prE X-Received: by 2002:a17:902:b112:b0:1ac:6e1f:d19c with SMTP id q18-20020a170902b11200b001ac6e1fd19cmr5157798plr.41.1685191524562; Sat, 27 May 2023 05:45:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685191524; cv=none; d=google.com; s=arc-20160816; b=Aua2/2/MCUTlJ0fse36wZIoUEi6j9Js7Lr5mwEDDAremzW2LpO4Rpd0VI2YecTKQzf pPfKVKxnrpIgh06LHtvuTW5Mezd/GfOResDGS0d4PdiWv0HuvZGFSF87i+nePw8UNx4d +xgQFh76yVKhXMTBqj+ltC0o/4oLJr9Ebs5a6zmAKgxwUELp+FMzy+Sl9YmWLVwniEJM ObNAkzrwrAiv6FfyI+q3YZooYOiJ1MiSTDXJS5UOPBJRfjeDsjjyw0rlAl4Sg/267BOV lP7LYOvZKUnQZUJ3QubjAehImROKVF1bRuVhk6AHO3XQ7qhj86tq55v1bcNs8/UwYX7O N5FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CUP6nBkgrdvZW7dvpRkHgWKqxWP2IxmsAM9FafkcDZY=; b=XDmP6mbfFInTb3sRrk7lPzpGUbl2xTXnlPTM5NWYgauCeI+4/RgqJbgEwSGFRB066J 8zMHBKK2JyTBz4hI1hgGZxqddnxXpk5n3yKsQMxxZbufi5MkFxRgiMvUGeNcpXGu90ys n4a1X1ZSLPUKW+ABCI2D45cQz+/CIIvSVUFIPWB4Ec8+400An7eVpaT+isT40Lg6e8m4 6GrGLaHqnwaCsCHXnjpUv3drX5RaGJ768xcM5iyWrjjYAEhFq4nxuAMJRg+z5IBXON2p efPieqU23s+PAxkG/TFa4yhK3g/kwdDdfN9gLEEierVb8E1NW4O86ZmreD3ti/cXefjY 5f5g== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k8-20020a170902c40800b001a637615a89si7092573plk.561.2023.05.27.05.45.09; Sat, 27 May 2023 05:45:24 -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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229717AbjE0MgO (ORCPT + 99 others); Sat, 27 May 2023 08:36:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232541AbjE0MgL (ORCPT ); Sat, 27 May 2023 08:36:11 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B3A91BB for ; Sat, 27 May 2023 05:35:51 -0700 (PDT) Received: from dggpemm500006.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QT1V75096zTkf3; Sat, 27 May 2023 20:35:43 +0800 (CST) Received: from thunder-town.china.huawei.com (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Sat, 27 May 2023 20:35:47 +0800 From: Zhen Lei To: Eric Biederman , Baoquan He , , CC: Zhen Lei , Michael Holzheu , Andrew Morton , Amerigo Wang Subject: [PATCH 2/6] kexec: delete a useless check in crash_shrink_memory() Date: Sat, 27 May 2023 20:34:35 +0800 Message-ID: <20230527123439.772-3-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.37.3.windows.1 In-Reply-To: <20230527123439.772-1-thunder.leizhen@huawei.com> References: <20230527123439.772-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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 The check '(crashk_res.parent != NULL)' is added by commit e05bd3367bd3 ("kexec: fix Oops in crash_shrink_memory()"), but it's stale now. Because if 'crashk_res' is not reserved, it will be zero in size and will be intercepted by the above 'if (new_size >= old_size)'. Ago: if (new_size >= end - start + 1) Now: old_size = (end == 0) ? 0 : end - start + 1; if (new_size >= old_size) Signed-off-by: Zhen Lei --- kernel/kexec_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 22acee18195a591..d1ab139dd49035e 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -1137,7 +1137,7 @@ int crash_shrink_memory(unsigned long new_size) end = start + new_size; crash_free_reserved_phys_range(end, crashk_res.end); - if ((start == end) && (crashk_res.parent != NULL)) + if (start == end) release_resource(&crashk_res); ram_res->start = end; -- 2.25.1