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 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F3C5103A9A1 for ; Wed, 25 Mar 2026 02:57:52 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fgWmJ3MSGz2yTK; Wed, 25 Mar 2026 13:57:36 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=113.46.200.216 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1774407456; cv=none; b=ZprQL8E422m5aBm+ARsR8o53Q8SzI/nXShE07vDPVkiZOPs20S+mZuQJJJ6BZ6IAUR2dA9ko0XeY1tK0A5ddMbFSiYJnxgmR933oDrNSUHA+c+bmSBCcSJ3gV+RVETLiF77XqRpB6NHTLQfaTq7AQVZ2oVvImfYDYpEoT3que0DZJFfW4MqmdmtnsDl03TQnMILKcPzGL06K5kkrCFkNLWMXdkth82QEnDBsB2N3Q+1/UkOewvIMD5G0WeiPCoe0boldmNxue3fogipNfaEy/Rvt8lFH1uNg4bmJw2bdO22Cwt63TqxNNW1M8sVN4xbx0JH3Y/Gq5tGg3Ar8xRYZBA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1774407456; c=relaxed/relaxed; bh=/i6VxgmNfg5cptySEU9CsbiBxFSCKM3OfYrwIMNa32Y=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=go7XtAbqCJTSA2KCG7I7AM4nAVMpgygJL6dpAIOfRGC1fCy0pYR95F2QyyS71hw1wLAuWXNzzgEUdKhIbarkxae44dniAUSiAouEFW7M15hPL53oBt/hhNYX1vP0bC618Q6fZHUPO30bHZ4rAF/PZpLRI0cT4dwAhQ0ObEd23EZLdMbgp+fLtXmcKkQBGOUJXa4FFhW/yrN5fjGziZAOT+adXDb+RGzSW/+wUpRYFcesSKy3eq1opH0RTf0YsgkTeo6VnqE2mMrSAGoBIYjCvhmUyKAXZe/CD4MePJWvRtLz+tqGV4ibuEf+oRhyhszrm0CIGuK971fdfPy0Fz5U2Q== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=ivD1fPbT; dkim-atps=neutral; spf=pass (client-ip=113.46.200.216; helo=canpmsgout01.his.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=ivD1fPbT; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=113.46.200.216; helo=canpmsgout01.his.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from canpmsgout01.his.huawei.com (canpmsgout01.his.huawei.com [113.46.200.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fgWmH1gMjz2yr8 for ; Wed, 25 Mar 2026 13:57:34 +1100 (AEDT) dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=/i6VxgmNfg5cptySEU9CsbiBxFSCKM3OfYrwIMNa32Y=; b=ivD1fPbTzEYIJATMUPqbbryzgl7/XSZpHThXqBefheozkff0gSztd7U9PEHTUquuHnasS9xc2 mfTtj6jOikZBW+4M7XNr7Mn9Kz/8Fosc1CbU1SZGOjMp8hXNmqG/SEzSLJ+0fWa03btTTiY+eqQ 6UVj+DXWUth+j08yU/82eDs= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4fgWdr14vwz1T4Fq; Wed, 25 Mar 2026 10:52:00 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id CFB984056A; Wed, 25 Mar 2026 10:57:30 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 25 Mar 2026 10:57:27 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 2/8] powerpc/crash: Fix possible memory leak in update_crash_elfcorehdr() Date: Wed, 25 Mar 2026 10:58:58 +0800 Message-ID: <20260325025904.2811960-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260325025904.2811960-1-ruanjinjie@huawei.com> References: <20260325025904.2811960-1-ruanjinjie@huawei.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To dggpemf500011.china.huawei.com (7.185.36.131) In get_crash_memory_ranges(), if crash_exclude_mem_range() failed after realloc_mem_ranges() has successfully allocated the cmem memory, it just returns an error but leaves cmem pointing to the allocated memory, nor is it freed in the caller update_crash_elfcorehdr(), which cause a memory leak, goto out to free the cmem. Fixes: 849599b702ef ("powerpc/crash: add crash memory hotplug support") Signed-off-by: Jinjie Ruan --- arch/powerpc/kexec/crash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kexec/crash.c b/arch/powerpc/kexec/crash.c index a325c1c02f96..1d12cef8e1e0 100644 --- a/arch/powerpc/kexec/crash.c +++ b/arch/powerpc/kexec/crash.c @@ -440,7 +440,7 @@ static void update_crash_elfcorehdr(struct kimage *image, struct memory_notify * ret = get_crash_memory_ranges(&cmem); if (ret) { pr_err("Failed to get crash mem range\n"); - return; + goto out; } /* -- 2.34.1