From nobody Fri Sep 25 18:20:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 A891B5540AB; Wed, 9 Sep 2026 13:13:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788959591; cv=none; b=M8cjE/0ID9ACUEHw7WEEqrYHmOpRezWD7OIgdoBJiF3BFtODHvDk05qafqLYiJXre484aXuX0OP8PGR7x6KxTjpO2BXAKjuj6x7BnRIazX61Xn9OhUW4G+3TCweDyqHuSYaYry0ONUmf/mmGGmtn4Ovkk4qrI8nttzkSoiYzfIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788959591; c=relaxed/simple; bh=Cco0eLYO5xHXTcrEHeQMkw1fFhGetnR/HOL25tY05Hc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C7aJlc1lgzUZp6Qmj2vLsz4BPHaWp4RlBgZEqtYLbjTgbqugNDW7kRCM2FnYlhQE1h1cNvngkHGoJQjnWW1AX6KrCSQkuiXVTcsjRnxLhhoByXu1r/puFr3IB02LzzqhIVDRfnY9dKu6XLjTSDQgbG0C8TS5ao5cBdVHQIre5+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OabBCNAE; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OabBCNAE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E0FA1F00A3F; Wed, 9 Sep 2026 13:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788959590; bh=exrp9sOpIrw8gCLYhyGLzFm16RZmIHh9nMD7AtHeshY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OabBCNAEx8zSE+TP2oDCidL0efN3Oy7t7e7v9T4Azc3+UhgIwGKm6KxJKZwVGqHi1 5I+8gQ9CHwYydhf0Ix6bPUzni23iNb8iDirKCHPs9MIIHyZOl9lz5nJgTuTy7dbIGF prauwfrLO68//1scK40MV1dmX+x7Z+YcjrTR+7h07B2HvE8Eu2cOaPB5Jn7oO5zA/u 77lLXzkUC2iXwj+YS8LqdnuMwJNuezTRFbYNv89ZgMnEwpopKtd1yrftippGhvnzZb gFtq3gI/jkVfWCrRFR54USf13QSZMWV1n0RcJM2Rtgrg6NW76FHFrxDEp1dUzJSlRt TV2Wj3RHQIQjw== From: Dinh Nguyen To: bp@alien8.de, tony.luck@intel.com Cc: dinguyen@kernel.org, rounakdas2025@gmail.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCHv4 1/4] EDAC/altera: Do not allow driver unbinding Date: Wed, 9 Sep 2026 08:12:50 -0500 Message-ID: <20260909131253.2158486-2-dinguyen@kernel.org> X-Mailer: git-send-email 2.42.0.411.g813d9a9188 In-Reply-To: <20260909131253.2158486-1-dinguyen@kernel.org> References: <20260909131253.2158486-1-dinguyen@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The EDAC driver must remain bound; unbinding and re-binding it would erase active system memory. Remove the .remove functions because they will not ever get used. Fixes: 588cb03ea208 ("EDAC, altera: Add Arria10 L2 Cache ECC handling") Cc: stable@vger.kernel.org Signed-off-by: Dinh Nguyen --- v4: rebased to edac-urgent v3: simplify commit messsage v2: reworked v1 to include only true sashiko hits --- drivers/edac/altera_edac.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c index 68846f583eeef..fe501c89dd0dc 100644 --- a/drivers/edac/altera_edac.c +++ b/drivers/edac/altera_edac.c @@ -453,15 +453,6 @@ static int altr_sdram_probe(struct platform_device *pd= ev) return res; } =20 -static void altr_sdram_remove(struct platform_device *pdev) -{ - struct mem_ctl_info *mci =3D platform_get_drvdata(pdev); - - edac_mc_del_mc(&pdev->dev); - edac_mc_free(mci); - platform_set_drvdata(pdev, NULL); -} - /* * If you want to suspend, need to disable EDAC by removing it * from the device tree or defconfig. @@ -481,13 +472,13 @@ static const struct dev_pm_ops altr_sdram_pm_ops =3D { =20 static struct platform_driver altr_sdram_edac_driver =3D { .probe =3D altr_sdram_probe, - .remove =3D altr_sdram_remove, .driver =3D { .name =3D "altr_sdram_edac", #ifdef CONFIG_PM .pm =3D &altr_sdram_pm_ops, #endif .of_match_table =3D altr_sdram_ctrl_of_match, + .suppress_bind_attrs =3D true, }, }; =20 @@ -517,6 +508,7 @@ static struct platform_driver altr_edac_driver =3D { .driver =3D { .name =3D "socfpga_ecc_manager", .of_match_table =3D altr_edac_of_match, + .suppress_bind_attrs =3D true, }, }; module_platform_driver(altr_edac_driver); @@ -803,22 +795,12 @@ static int altr_edac_device_probe(struct platform_dev= ice *pdev) return res; } =20 -static void altr_edac_device_remove(struct platform_device *pdev) -{ - struct edac_device_ctl_info *dci =3D platform_get_drvdata(pdev); - struct altr_edac_device_dev *drvdata =3D dci->pvt_info; - - debugfs_remove_recursive(drvdata->debugfs_dir); - edac_device_del_device(&pdev->dev); - edac_device_free_ctl_info(dci); -} - static struct platform_driver altr_edac_device_driver =3D { .probe =3D altr_edac_device_probe, - .remove =3D altr_edac_device_remove, .driver =3D { .name =3D "altr_edac_device", .of_match_table =3D altr_edac_device_of_match, + .suppress_bind_attrs =3D true, }, }; module_platform_driver(altr_edac_device_driver); @@ -2214,6 +2196,7 @@ static struct platform_driver altr_edac_a10_driver = =3D { .driver =3D { .name =3D "socfpga_a10_ecc_manager", .of_match_table =3D altr_edac_a10_of_match, + .suppress_bind_attrs =3D true, }, }; module_platform_driver(altr_edac_a10_driver); --=20 2.42.0.411.g813d9a9188 From nobody Fri Sep 25 18:20:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 8B30A55D864; Wed, 9 Sep 2026 13:13:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788959592; cv=none; b=kTtGOYgtUGD+ywrW94eor3CPthUAJtQaO14KRgGN+8+drLiH7nMrbl4fLmfVmEBi2c/0G2UO+m+gps6j9QYbKy6e0JBW1mpwhQyu75PN3g6AnH8ua0u38Zk5lBJb7fB3nTUHoVFC1y7UPZzTsUm3hzwHa0vn5L5SCKSUchgvPTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788959592; c=relaxed/simple; bh=wLRsMKY8OEFYi/qpDoXeA9FEh4qReWhoZVAfNrO7wJ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qxS3AEZ3qO12uBJF6II+193HCABxe7hI9vQkKiOfh6taknCI70TEe3QasKzQ920I+ASw02NMEOk7rjl+HWqhEFNF/RZQKgRP8f8euYowSxPveGbxzbfyGVMIfs25CrlSSfI4iw+lrWjUTLDGWMm6/4cYQyg4+8V6T47crQfYuVs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=REV+ikR6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="REV+ikR6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C19DB1F00A3E; Wed, 9 Sep 2026 13:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788959591; bh=8TPPTfwBtiaYCUK4EzlWzn+yAl6kg3Gs5FBkRSt9/E8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=REV+ikR695iv2Yn/vw+epDqUgyGHmoYlVz0kqEn2itk/fygs3bHLYnJdB3UlJCx1L SEFjW9t/CFKB2i1UBl6VbYJFjQFqTJolkv4XK2NCX8nywN2EEljtwuGnKri3VKnXEI gNIpd+GddSWt8eUTO7J6YvtfyoF1h/TW93IRvu+BORgXLdsB6u41dk9bGzu44Dejcw bcg2iutKc7CMTIDwIiWf35l+3FcecZVizTK6nTwtr+HLQxLWsz3zmMwGBu/zSMVaoN k/p2jff80ToxGHKThbAMV86ysT8JNqvGW/JbqqWhunGIEHr0sDB2yGmKs/G7kSz7ca 8Ey2zpQfyjxkw== From: Dinh Nguyen To: bp@alien8.de, tony.luck@intel.com Cc: dinguyen@kernel.org, rounakdas2025@gmail.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCHv4 2/4] EDAC/altera: Drop __init from ECC setup paths for re-probe safety Date: Wed, 9 Sep 2026 08:12:51 -0500 Message-ID: <20260909131253.2158486-3-dinguyen@kernel.org> X-Mailer: git-send-email 2.42.0.411.g813d9a9188 In-Reply-To: <20260909131253.2158486-1-dinguyen@kernel.org> References: <20260909131253.2158486-1-dinguyen@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" sashiko reports: Does suppressing sysfs unbinding fully prevent the execution of freed __init memory? If altr_sysmgr_regmap_lookup_by_phandle() returns -EPROBE_DEFER, the probe is deferred until after __init memory is freed. The a10 EDAC .setup callbacks (sdmmc, ethernet, nand, dma, usb, qspi) and their helpers (altr_init_a10_ecc_device_type, altr_init_a10_ecc_block) were marked __init. These run from the probe path, which may execute after init memory is freed -- e.g. a probe deferred via -EPROBE_DEFER that only succeeds once a late/module dependency appears, or a manual unbind/rebind. Calling __init code then dereferences freed memory. Remove __init so these functions remain valid at runtime. Assisted-by: Cursor:claude-4.8-opus Fixes: 788586efd116 ("EDAC/altera: Initialize peripheral FIFOs in probe()) Cc: stable@vger.kernel.org Signed-off-by: Dinh Nguyen --- v4: rebased to edac-urgent v3: no changes v2: reworked v1 to include only true sashiko hits --- drivers/edac/altera_edac.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c index fe501c89dd0dc..d8a3438fb5f44 100644 --- a/drivers/edac/altera_edac.c +++ b/drivers/edac/altera_edac.c @@ -926,7 +926,7 @@ static int __maybe_unused altr_init_memory_port(void __= iomem *ioaddr, int port) return ret; } =20 -static __init int __maybe_unused +static int __maybe_unused altr_init_a10_ecc_block(struct device_node *np, u32 irq_mask, u32 ecc_ctrl_en_mask, bool dual_port) { @@ -1001,7 +1001,7 @@ altr_init_a10_ecc_block(struct device_node *np, u32 i= rq_mask, =20 static int validate_parent_available(struct device_node *np); static const struct of_device_id altr_edac_a10_device_of_match[]; -static int __init __maybe_unused altr_init_a10_ecc_device_type(char *compa= t) +static int __maybe_unused altr_init_a10_ecc_device_type(char *compat) { int irq; struct device_node *child, *np; @@ -1330,7 +1330,7 @@ static const struct edac_device_prv_data a10_l2ecc_da= ta =3D { =20 #ifdef CONFIG_EDAC_ALTERA_ETHERNET =20 -static int __init socfpga_init_ethernet_ecc(struct altr_edac_device_dev *d= ev) +static int socfpga_init_ethernet_ecc(struct altr_edac_device_dev *dev) { int ret; =20 @@ -1360,7 +1360,7 @@ static const struct edac_device_prv_data a10_enetecc_= data =3D { =20 #ifdef CONFIG_EDAC_ALTERA_NAND =20 -static int __init socfpga_init_nand_ecc(struct altr_edac_device_dev *devic= e) +static int socfpga_init_nand_ecc(struct altr_edac_device_dev *device) { int ret; =20 @@ -1390,7 +1390,7 @@ static const struct edac_device_prv_data a10_nandecc_= data =3D { =20 #ifdef CONFIG_EDAC_ALTERA_DMA =20 -static int __init socfpga_init_dma_ecc(struct altr_edac_device_dev *device) +static int socfpga_init_dma_ecc(struct altr_edac_device_dev *device) { int ret; =20 @@ -1420,7 +1420,7 @@ static const struct edac_device_prv_data a10_dmaecc_d= ata =3D { =20 #ifdef CONFIG_EDAC_ALTERA_USB =20 -static int __init socfpga_init_usb_ecc(struct altr_edac_device_dev *device) +static int socfpga_init_usb_ecc(struct altr_edac_device_dev *device) { int ret; =20 @@ -1450,7 +1450,7 @@ static const struct edac_device_prv_data a10_usbecc_d= ata =3D { =20 #ifdef CONFIG_EDAC_ALTERA_QSPI =20 -static int __init socfpga_init_qspi_ecc(struct altr_edac_device_dev *devic= e) +static int socfpga_init_qspi_ecc(struct altr_edac_device_dev *device) { int ret; =20 @@ -1598,7 +1598,7 @@ static int altr_portb_setup(struct altr_edac_device_d= ev *device) return rc; } =20 -static int __init socfpga_init_sdmmc_ecc(struct altr_edac_device_dev *devi= ce) +static int socfpga_init_sdmmc_ecc(struct altr_edac_device_dev *device) { int rc =3D -ENODEV; struct device_node *child; --=20 2.42.0.411.g813d9a9188 From nobody Fri Sep 25 18:20:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0BA6E550DC3; Wed, 9 Sep 2026 13:13:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788959593; cv=none; b=LrLbiOqkfMA1vbEBh1bZiBs2kLK2kr412lGLgLFTqu5ZAC0Rx2Fb4Jxald1NxIWr3Zt3CDZemKUT267rnhk5A8bAH+Ymsq6AkuxS4jDIv6qcP6dKKeadujEOK0eMpSPPKMh4U5F/wamH4s1V5yGVquBlyquu2dyaJBcAuGSumPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788959593; c=relaxed/simple; bh=/flwUTsnBb5pJV3uqQagfzKUQZrYrmEI2hn3JX4TTTM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xmr9DCZk3eW3nJU+OaF9pfnEifkrnTSYIXd2FigqCVWCySm05+x3/sCy1oVcXiUkjy+ppgeCl0GGoFSLb0mC/iduSwxRroqIfwKIjxRgBbbIWKTwuIUhAcr6fRYCr73E6YqtqjNO81aMydOqkHJMx6+DdIlzBLwYKfmVPpbd8eo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Od30AXtH; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Od30AXtH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7469F1F00A3A; Wed, 9 Sep 2026 13:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788959591; bh=Iw3up/37K0JEJR2NToWqFDiwdxlhN8ItBMVuaFF4dA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Od30AXtHNUifWmX7eMgpGUrLzJN9FL5ljuc4bOxHNSaGNLtqdfx7pS3f4vd39LHIQ 0flGungmeL6eBAFnTgdUlhTlyHvVdQFhWjrEK+rBv3rJ7v13A2AVqhlGitYO0nmegE Gi3LWlVOdw+6D4vOwL6oxexvgOwMH43PquinI+Jdtr0yaotRA/zsKIEdo5j3Vtk3Dv CUUgBWM+NLSBHuCjFSFSqTpN0oPxkBIW6tbJ1+xeTenzRyic2Eh/pOpBp9mJ6yunTT M/co4W8A95aTnPr9KgXy+ecRP/OWHJp0qKvSTSbU4sR0wOfIMb7LIjSDvDjZG9j33H gqoAyXKvwhviA== From: Dinh Nguyen To: bp@alien8.de, tony.luck@intel.com Cc: dinguyen@kernel.org, rounakdas2025@gmail.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCHv4 3/4] EDAC/altera: Fix code leak on dci allocation failure Date: Wed, 9 Sep 2026 08:12:52 -0500 Message-ID: <20260909131253.2158486-4-dinguyen@kernel.org> X-Mailer: git-send-email 2.42.0.411.g813d9a9188 In-Reply-To: <20260909131253.2158486-1-dinguyen@kernel.org> References: <20260909131253.2158486-1-dinguyen@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" sashiko reports: If devres_open_group() fails, the function returns -ENOMEM without freeing the dci structure allocated earlier with edac_device_alloc_= ctl_info(). Free the dci structure if devres_open_group() fails. Fixes: c3eea1942a16 ("EDAC, altera: Add Altera L2 cache and OCRAM support") Cc: stable@vger.kernel.org Signed-off-by: Dinh Nguyen --- v4: rebased to edac-urgent v3: No changes v2: reworked v1 to include only true sashiko hits --- drivers/edac/altera_edac.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c index d8a3438fb5f44..4b289b90186f9 100644 --- a/drivers/edac/altera_edac.c +++ b/drivers/edac/altera_edac.c @@ -1517,7 +1517,9 @@ static int altr_portb_setup(struct altr_edac_device_d= ev *device) *altdev =3D *device; =20 if (!devres_open_group(device->edac->dev, altr_portb_setup, GFP_KERNEL)) + edac_device_free_ctl_info(dci); return -ENOMEM; + } =20 /* Update PortB specific values */ altdev->edac_dev_name =3D ecc_name; --=20 2.42.0.411.g813d9a9188 From nobody Fri Sep 25 18:20:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 DEE9A560ADA; Wed, 9 Sep 2026 13:13:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788959594; cv=none; b=eiHGVr2M9+UxajYeWoNzSwXPnk+lzZNZln3B6hmlWzw1lWHaAZuhG2DrvbhjfSlPJuDmZ4BUeQMT9aIfWCfDL2kjr9xViNKoGkbaQWjxoCdjTeBFSV0OsOjUtU5UgNmtbLf0aXqnaCdvGAvM7qOhGlEtBkLqFH6rrfD1a37p348= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788959594; c=relaxed/simple; bh=vdfy9W8DpRTIzGtNaxE8tSbHUeibs9uxNTU1sWMs7ug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MbAPBBa07nwQ/798WOmrWgt8Ygz2F+d5ORoeI0KusBQPYcHP+ndlwHsKhCVUMjLE5J6GTKL5feCRkOCdk2Y1KEoCvrckaUC87u8nyGCkPz4nMx5Dt1LkkFa3LbbE0AkMQkqhuCcLg0PRgUaYJGpXOHfHsJc8FwyQXJC81trLE7c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hblcrCH9; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hblcrCH9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 225361F00A3D; Wed, 9 Sep 2026 13:13:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788959592; bh=nXgz50FbWhpnvfTGySvPlnSPlStDRwK/0Rn8bC0H3lY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hblcrCH9Mt8nGVJpJ+OQCzPMVu19eV+r6Yz2hkYYC9bkcKrjvG/V7T+0CnU4k4wD0 nFjFWNECuD7rkN6VvEVQ3GGYYM6zftlEuoSzBnqT0IoJ/06aItyxmUQttMM1ZkosCT cadwTWIvWda4o7KV+m6bOtMmsrA1HwIlAbD/54e8m+wQ+AGqimq4urc9F/B9SPoePR eP0rtXGHeb8KfPTflwJMlnsO9u0TC7WviojVy65Tqm5lt1xykpxvLG9AZFiz7IZMj0 3ZZnuUliyE01JX+2k1UhYnKcztrnwpPK8iptuufWJPPkwNnE38OP9COeJI696oRLEc qW5V+u3ziC/mg== From: Dinh Nguyen To: bp@alien8.de, tony.luck@intel.com Cc: dinguyen@kernel.org, rounakdas2025@gmail.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCHv4 4/4] EDAC/altera: Fix use-after-free in error paths Date: Wed, 9 Sep 2026 08:12:53 -0500 Message-ID: <20260909131253.2158486-5-dinguyen@kernel.org> X-Mailer: git-send-email 2.42.0.411.g813d9a9188 In-Reply-To: <20260909131253.2158486-1-dinguyen@kernel.org> References: <20260909131253.2158486-1-dinguyen@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In both altr_edac_a10_device_add() and altr_portb_setup(), the error path freed the dci structure before releasing the devres group. Since the managed single and double bit IRQ handlers use altdev(dci->pvt_info) as their data,= an IRQ firing between freeing dci and unregistering the IRQs could dereference the freed memory. Release the devres group first so the managed IRQs are unregistered before the dci structure is freed. Assisted-by: Cursor:claude-4.8-opus Fixes: 911049845d70 ("EDAC, altera: Add Arria10 SD-MMC EDAC support") Fixes: 588cb03ea208 ("EDAC, altera: Add Arria10 L2 Cache ECC handling") Closes: https://sashiko.dev/#/patchset/20260719211238.589402-1-rosenp%40gma= il.com Cc: stable@vger.kernel.org Signed-off-by: Dinh Nguyen --- v4: rebased to edac-urgent v3: No changes v2: reworked v1 to include only true sashiko hits --- drivers/edac/altera_edac.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c index 4b289b90186f9..6fc474ec3811d 100644 --- a/drivers/edac/altera_edac.c +++ b/drivers/edac/altera_edac.c @@ -1593,8 +1593,13 @@ static int altr_portb_setup(struct altr_edac_device_= dev *device) return 0; =20 err_release_group_1: - edac_device_free_ctl_info(dci); + /* + * Release the devres group first so the managed IRQs are + * unregistered before dci (which contains the IRQ handler's + * data via dci->pvt_info) is freed, avoiding a use-after-free. + */ devres_release_group(device->edac->dev, altr_portb_setup); + edac_device_free_ctl_info(dci); edac_printk(KERN_ERR, EDAC_DEVICE, "%s:Error setting up EDAC device: %d\n", ecc_name, rc); return rc; @@ -1997,9 +2002,17 @@ static int altr_edac_a10_device_add(struct altr_arri= a10_edac *edac, return 0; =20 err_release_group1: + /* + * Release the devres group first so the managed IRQs are + * unregistered before dci (which contains the IRQ handler's + * data via dci->pvt_info) is freed, avoiding a use-after-free. + */ + devres_release_group(edac->dev, NULL); edac_device_free_ctl_info(dci); + goto err_print; err_release_group: devres_release_group(edac->dev, NULL); +err_print: edac_printk(KERN_ERR, EDAC_DEVICE, "%s:Error setting up EDAC device: %d\n", ecc_name, rc); =20 --=20 2.42.0.411.g813d9a9188