From nobody Mon Feb 9 16:17:11 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DED84C77B7E for ; Sat, 27 May 2023 12:36:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232577AbjE0MgZ (ORCPT ); Sat, 27 May 2023 08:36:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232555AbjE0MgM (ORCPT ); Sat, 27 May 2023 08:36:12 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15C6B1BD for ; Sat, 27 May 2023 05:35:51 -0700 (PDT) Received: from dggpemm500006.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4QT1Nz3J4hz18LRM; Sat, 27 May 2023 20:31:15 +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:48 +0800 From: Zhen Lei To: Eric Biederman , Baoquan He , , CC: Zhen Lei , Michael Holzheu , Andrew Morton , Amerigo Wang Subject: [PATCH 3/6] kexec: clear crashk_res if all its memory has been released Date: Sat, 27 May 2023 20:34:36 +0800 Message-ID: <20230527123439.772-4-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: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If the resource of crashk_res has been released, it is better to clear crashk_res.start and crashk_res.end. Because 'end =3D start - 1' is not reasonable, and in some places the test is based on crashk_res.end, not resource_size(&crashk_res). Signed-off-by: Zhen Lei Acked-by: Baoquan He --- kernel/kexec_core.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index d1ab139dd49035e..bcc86a250ab3bf9 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -1137,15 +1137,18 @@ int crash_shrink_memory(unsigned long new_size) end =3D start + new_size; crash_free_reserved_phys_range(end, crashk_res.end); =20 - if (start =3D=3D end) - release_resource(&crashk_res); - ram_res->start =3D end; ram_res->end =3D crashk_res.end; ram_res->flags =3D IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM; ram_res->name =3D "System RAM"; =20 - crashk_res.end =3D end - 1; + if (start =3D=3D end) { + release_resource(&crashk_res); + crashk_res.start =3D 0; + crashk_res.end =3D 0; + } else { + crashk_res.end =3D end - 1; + } =20 insert_resource(&iomem_resource, ram_res); =20 --=20 2.25.1