[PATCH] memory: emif: Put the DDR node on probe failure
From: Yige Jiang
Date: Mon Nov 23 2026 - 12:38:40 EST
of_get_memory_device_details() returns an emif_data holding a reference
to the DDR device node. Although the helper's failures and emif_remove()
now release that reference, emif_probe() still leaks it when mapping the
registers, obtaining the IRQ, or setting up the interrupts fails.
Route those three failures through an of_node_put() before returning.
Keep the existing path for failures to obtain the device details, which
have already handled their node reference. The non-DT path is safe too,
since its zero-initialized np_ddr remains NULL.
Fixes: e6b42eb6a66c ("memory: emif: add device tree support to emif driver")
Signed-off-by: Yige Jiang <yigejiang86@xxxxxxxxx>
---
AI assistance was used for analysis and patch preparation.
Based on next-20261104 (8b7179210b22).
Compile-tested: arm64, GCC 14.2.0, W=1, drivers/memory/emif.o;
baseline and patched objects built with no warnings.
Static source review; no hardware, boot, or KASAN test was performed.
drivers/memory/emif.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c
index 886c2ca0dc19d4388feb6f8670aa6cd579e426b0..68b12528968fd1b8db310d51a008f6abdfd75718 100644
--- a/drivers/memory/emif.c
+++ b/drivers/memory/emif.c
@@ -1106,18 +1106,18 @@ static int emif_probe(struct platform_device *pdev)
emif->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(emif->base))
- goto error;
+ goto put_node;
irq = platform_get_irq(pdev, 0);
if (irq < 0)
- goto error;
+ goto put_node;
emif_onetime_settings(emif);
emif_debugfs_init(emif);
disable_and_clear_all_interrupts(emif);
ret = setup_interrupts(emif, irq);
if (ret)
- goto error;
+ goto put_node;
/* One-time actions taken on probing the first device */
if (!emif1) {
@@ -1134,6 +1134,8 @@ static int emif_probe(struct platform_device *pdev)
__func__, emif->base, irq);
return 0;
+put_node:
+ of_node_put(emif->np_ddr);
error:
return -ENODEV;
}
base-commit: 8b7179210b22f8e48a82c5ceacb9d56a9c4cfec4