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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 5E221C5B56A for ; Wed, 12 Aug 2026 05:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:CC:To:In-Reply-To:References :Message-ID:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9coy9Sufhm1XIV1j5IuQe3OBV2Y+v8SYIlL3q3e3IeY=; b=2cvZUMl8l3/s8HfFT7wgW3BUK2 ICS6xiGpWkdRNXij4RxWRF1BxqrLb7dd2wMNBHE+NtX92Kdc/wGeW3BVGhroLXk859YRJlqC1IJmK UvnONWzrxBhaBQoADDosXjCYG037PKWP2730y6DIi0xYBP/6SCba3pizRzfJ3qTCAxwahk2XJVZlW 5UUyQdoW9rE2tajnncox9SEZm61tH8pLlJ86gDnsuKFUo24EQOmbDI8ROgGqqeDkTQouFWvVsiHBz 3TyNHmDsPEhkrJg3PHQEn22dViAptTmQeSzPU0gNiXwpIVWgdJRvF6qmcX9jHWs3npwLAJEYx2iso XSHupgxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wu1pV-0000000FSdP-424n; Wed, 12 Aug 2026 05:48:45 +0000 Received: from mail.aspeedtech.com ([211.20.114.72] helo=twmbx01.aspeedtech.com) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wu1pR-0000000FSWa-2gdu for linux-arm-kernel@lists.infradead.org; Wed, 12 Aug 2026 05:48:42 +0000 Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Wed, 12 Aug 2026 13:48:26 +0800 Received: from [127.0.1.1] (192.168.10.13) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Wed, 12 Aug 2026 13:48:26 +0800 From: Ryan Chen Date: Wed, 12 Aug 2026 13:48:28 +0800 Subject: [PATCH 4/7] EDAC/aspeed: Free the mem_ctl_info unconditionally on remove MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20260812-edac-v1-4-03992edea297@aspeedtech.com> References: <20260812-edac-v1-0-03992edea297@aspeedtech.com> In-Reply-To: <20260812-edac-v1-0-03992edea297@aspeedtech.com> To: Stefan Schaeckeler , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , Borislav Petkov , Tony Luck , "Sebastian Andrzej Siewior" , Clark Williams , Steven Rostedt CC: , , , , , Borislav Petkov , , Ryan Chen X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1786513706; l=1411; i=ryan_chen@aspeedtech.com; s=20251126; h=from:subject:message-id; bh=yRn6gRtMLiLqMDInORTTYh92hg9HUS6B25U23zwFj3o=; b=ssnqIGmszPrfSMHYrqQ49TZhae/h/sTZ3GwA+RPn09RCCbhAP8Z4KVb+OO82ZhXy0cfSsUYep CUzsPZknQkDBRQ3tiym0RwK1UG3pJ08zptxQkKqRDJFr1s955CD26o3 X-Developer-Key: i=ryan_chen@aspeedtech.com; a=ed25519; pk=Xe73xY6tcnkuRjjbVAB/oU30KdB3FvG4nuJuILj7ZVc= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260811_224841_705577_0066FB29 X-CRM114-Status: GOOD ( 13.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org aspeed_remove() is a driver .remove callback, so it only runs for a device that has already probed successfully and registered its mem_ctl_info. In that case edac_mc_del_mc() always returns the same, valid pointer, and the NULL check on its return value can never be false. Fetch the mem_ctl_info from the platform device's driver data instead and free it unconditionally, dropping the redundant check. This also decouples the teardown from the return value of edac_mc_del_mc(). Signed-off-by: Ryan Chen --- drivers/edac/aspeed_edac.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c index 71535e0b6bad..8bfeb21d3204 100644 --- a/drivers/edac/aspeed_edac.c +++ b/drivers/edac/aspeed_edac.c @@ -343,16 +343,15 @@ static int aspeed_probe(struct platform_device *pdev) static void aspeed_remove(struct platform_device *pdev) { - struct mem_ctl_info *mci; + struct mem_ctl_info *mci = platform_get_drvdata(pdev); /* disable interrupts */ regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL, ASPEED_MCR_INTR_CTRL_ENABLE, 0); /* free resources */ - mci = edac_mc_del_mc(&pdev->dev); - if (mci) - edac_mc_free(mci); + edac_mc_del_mc(&pdev->dev); + edac_mc_free(mci); } static const struct of_device_id aspeed_of_match[] = { -- 2.34.1