From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from twmbx01.aspeedtech.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82F093F20FC; Wed, 7 Oct 2026 06:13:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.20.114.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791353628; cv=none; b=EZLPl3uYABDhZwxllWt2vXM1rkTyS46wNOyHxI+9Wnd9svXfwvZCABsiZpEOZTxnT7DM70wJSEa9fM05D2C/R4vRuED96igskvlIsSQ6K8/XmY5I51NkasKhNBuHdDRUKzTiIiAXb7k6fmPNvWLFZosnbMPx0VoBexYS06rQu9w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791353628; c=relaxed/simple; bh=Jeu93HngNXPqxP5kQEwwawVViBIF6aurqmZa1RE8cn8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=YKM/utCC5ywM4J7z8ymK9k0hXZW2hx2TRp4X4Nqoq8dZObsrcoVopMEnmL5A345J+2Vue03QizkqM/cA7zok0EiMSRhG3csfzjq2AbdK8v2ANXEsowsdWt5OMhQ5uG3gc0PK2Rs19qa9DUyIBSjseFWZHDpsAvm6QhWtDETa8hw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass smtp.mailfrom=aspeedtech.com; arc=none smtp.client-ip=211.20.114.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aspeedtech.com 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, 7 Oct 2026 14:13:19 +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, 7 Oct 2026 14:13:19 +0800 From: Ryan Chen Date: Wed, 7 Oct 2026 14:13:21 +0800 Subject: [PATCH v5 4/9] EDAC/aspeed: Free the mem_ctl_info unconditionally on remove Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20261007-edac-v5-4-5c31fc5df4cf@aspeedtech.com> References: <20261007-edac-v5-0-5c31fc5df4cf@aspeedtech.com> In-Reply-To: <20261007-edac-v5-0-5c31fc5df4cf@aspeedtech.com> To: Stefan Schaeckeler , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Joel Stanley , Andrew Jeffery , Borislav Petkov , Tony Luck CC: , , , , , Borislav Petkov , Ryan Chen X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791353599; l=1499; i=ryan_chen@aspeedtech.com; s=20251126; h=from:subject:message-id; bh=Jeu93HngNXPqxP5kQEwwawVViBIF6aurqmZa1RE8cn8=; b=JLarcacer4Pwhgu9S4CPBkXazIKSVYmTVDv5BYV6krpKlX7PSDdrAvuGxVXVvaB77Q/bu2OCj 6AXvShajSeUACEP9Hi7QEROHr9/xbhW+7VWhMVyk+OzV5dBEJsw0mpv X-Developer-Key: i=ryan_chen@aspeedtech.com; a=ed25519; pk=Xe73xY6tcnkuRjjbVAB/oU30KdB3FvG4nuJuILj7ZVc= 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 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/edac/aspeed_edac.c b/drivers/edac/aspeed_edac.c index bf1ff9a79d15..610da8aa2a22 100644 --- a/drivers/edac/aspeed_edac.c +++ b/drivers/edac/aspeed_edac.c @@ -345,18 +345,17 @@ 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_irq(aspeed_irq, platform_get_drvdata(pdev)); + free_irq(aspeed_irq, mci); /* 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