From: Dinh Nguyen <dinguyen@kernel.org>
To: bp@alien8.de, tony.luck@intel.com
Cc: dinguyen@kernel.org, rounakdas2025@gmail.com,
niravkumar.l.rabara@altera.com, linux-edac@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 07/10] EDAC/altera: Drop __init from ECC setup paths for re-probe safety
Date: Mon, 27 Jul 2026 08:24:13 -0500 [thread overview]
Message-ID: <20260727132416.807230-8-dinguyen@kernel.org> (raw)
In-Reply-To: <20260727132416.807230-1-dinguyen@kernel.org>
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())
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
---
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 cd2c2d11214d4..d8d2adc9c39ac 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -946,7 +946,7 @@ static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port)
return ret;
}
-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)
{
@@ -1021,7 +1021,7 @@ altr_init_a10_ecc_block(struct device_node *np, u32 irq_mask,
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 *compat)
+static int __maybe_unused altr_init_a10_ecc_device_type(char *compat)
{
int irq;
struct device_node *child, *np;
@@ -1350,7 +1350,7 @@ static const struct edac_device_prv_data a10_l2ecc_data = {
#ifdef CONFIG_EDAC_ALTERA_ETHERNET
-static int __init socfpga_init_ethernet_ecc(struct altr_edac_device_dev *dev)
+static int socfpga_init_ethernet_ecc(struct altr_edac_device_dev *dev)
{
int ret;
@@ -1380,7 +1380,7 @@ static const struct edac_device_prv_data a10_enetecc_data = {
#ifdef CONFIG_EDAC_ALTERA_NAND
-static int __init socfpga_init_nand_ecc(struct altr_edac_device_dev *device)
+static int socfpga_init_nand_ecc(struct altr_edac_device_dev *device)
{
int ret;
@@ -1410,7 +1410,7 @@ static const struct edac_device_prv_data a10_nandecc_data = {
#ifdef CONFIG_EDAC_ALTERA_DMA
-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;
@@ -1440,7 +1440,7 @@ static const struct edac_device_prv_data a10_dmaecc_data = {
#ifdef CONFIG_EDAC_ALTERA_USB
-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;
@@ -1470,7 +1470,7 @@ static const struct edac_device_prv_data a10_usbecc_data = {
#ifdef CONFIG_EDAC_ALTERA_QSPI
-static int __init socfpga_init_qspi_ecc(struct altr_edac_device_dev *device)
+static int socfpga_init_qspi_ecc(struct altr_edac_device_dev *device)
{
int ret;
@@ -1625,7 +1625,7 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
return rc;
}
-static int __init socfpga_init_sdmmc_ecc(struct altr_edac_device_dev *device)
+static int socfpga_init_sdmmc_ecc(struct altr_edac_device_dev *device)
{
int rc = -ENODEV;
struct device_node *child;
--
2.42.0.411.g813d9a9188
next prev parent reply other threads:[~2026-07-27 13:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 13:24 [PATCH 00/10] EDAC/altera: Address sashiko reviews part 1 Dinh Nguyen
2026-07-27 13:24 ` [PATCH 01/10] EDAC/altera: Fix NULL of_node dereference altr_edac_device_probe() Dinh Nguyen
2026-07-28 18:56 ` Borislav Petkov
2026-07-31 13:49 ` Dinh Nguyen
2026-07-27 13:24 ` [PATCH 02/10] EDAC/altera: Fix use-after-free in error paths Dinh Nguyen
2026-07-27 13:24 ` [PATCH 03/10] EDAC/altera: Guard against NULL match data in altr_sdram_probe() Dinh Nguyen
2026-07-27 13:24 ` [PATCH 04/10] EDAC/altera: Fix IRQ domain leak on platform_get_irq() failure Dinh Nguyen
2026-07-27 13:24 ` [PATCH 05/10] EDAC/altera: Fix code leak on dci allocation failure Dinh Nguyen
2026-07-27 13:24 ` [PATCH 06/10] EDAC/altera: Add suppress_bind_attrs so driver cannot get unbound Dinh Nguyen
2026-07-27 13:24 ` Dinh Nguyen [this message]
2026-07-27 13:24 ` [PATCH 08/10] EDAC/altera: Skip ECC memory init if already initialized Dinh Nguyen
2026-07-27 13:24 ` [PATCH 09/10] EDAC/altera: Detach sb_irq handler when db_irq setup fails Dinh Nguyen
2026-07-27 13:24 ` [PATCH 10/10] EDAC/altera: Fix error cleanup path in altr_edac_device_probe() Dinh Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260727132416.807230-8-dinguyen@kernel.org \
--to=dinguyen@kernel.org \
--cc=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=niravkumar.l.rabara@altera.com \
--cc=rounakdas2025@gmail.com \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®