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 CD226C5B56A for ; Wed, 12 Aug 2026 05:49:17 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hKcxL0g09z3brN; Wed, 12 Aug 2026 15:48:54 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1786513734; cv=none; b=jyHfEv40OPj36NRyOOvlNcfYb5EPpqcsZKK1OTevey0vYXaDwCz85+jQ/cr0Jsn6iyP0swlGVWfL6WIANuffAAqcmwOIEu0ERc23x2oaMFidLa06NJ/iFzHCqLUnI8nAm4Y+Is+wah8ZsehyBPfAY5nXsfT586FfNdhI3oQBSsJaXtDKfgFJNmccqmZcEYHx4HAGc2DtkA45NQgfLRCZ7DWIJcLoh6jqYe5KEKAIGKfxVsq+nDxct+puyd8+m1wSPJNOCGeZl1fPJG9dIZb0ul+F8EWz9lODNp6mDAAwrmTwTm9MvqgyynONjh0HWeWJuvzgN5Nd+zgxvEfWv+atVg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1786513734; c=relaxed/relaxed; bh=9coy9Sufhm1XIV1j5IuQe3OBV2Y+v8SYIlL3q3e3IeY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=WDBLbxhVqzBpXXvFbRrQwmiJij0cG9sBbf1MnWb52+J8jnpEM0ylNv1DOLgWA5b6gz41a6UL71wHXRI2UG/APuJwU4fYobm7AvNuB5385ZLBARMW9YOEX8IzCH1IaDxgcSl7/p3yzQaHHBJYAHgvfnattrmSh1hviQCvaejOY8o6YAH5o9n8C1sipx9z8u3JG9tseDUkwfpwiziOGswweYeDT/QbLQiF0d17X4/3lSpokqbRSJbC8G2AzgQnb/gWhNcTllYqNNjhavcpiM6T0JHkYgU/qjICCwyvHyhZ/9HtPUfkJfaumaPLDLu5nR+ljEaViRhSZkLmmklynBmjqw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) smtp.mailfrom=aspeedtech.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aspeedtech.com (client-ip=211.20.114.72; helo=twmbx01.aspeedtech.com; envelope-from=ryan_chen@aspeedtech.com; receiver=lists.ozlabs.org) 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 lists.ozlabs.org (Postfix) with ESMTPS id 4hKcxK2jVZz3brL for ; Wed, 12 Aug 2026 15:48:53 +1000 (AEST) 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 X-Mailing-List: linux-aspeed@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list 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= 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