[PATCH] mtd: rawnand: omap2: release the ELM device node reference
From: Yige Jiang
Date: Thu Oct 29 2026 - 08:04:08 EST
omap_get_dt_info() acquires an ELM node reference through ti,elm-id
or the legacy elm_id phandle, but never releases it. The existing
put_device(info->elm_dev) releases a separate device reference.
Register a managed of_node_put() action immediately after parsing the
phandle. This releases the node on later parsing and probe failures
and after NAND cleanup on unbind. If action registration fails,
devm_add_action_or_reset() releases the reference immediately.
Fixes: c9711ec5250b ("mtd: nand: omap: Clean up device tree support")
Assisted-by: LLM
Signed-off-by: Yige Jiang <yigejiang86@xxxxxxxxx>
---
Based on linux-next next-20261016 (2efb7a11f1aa).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_OF_DYNAMIC=y.
COMPILE_TEST=y.
The object was built from this exact base with the patch applied.
No full kernel or module-link, hardware or runtime test was performed.
drivers/mtd/nand/raw/omap2.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/mtd/nand/raw/omap2.c b/drivers/mtd/nand/raw/omap2.c
index 4fa89aee934ebed9d04dd37e441243b6779af042..25414390af6174bc5f5e4b6b6c4fe516ac646cb8 100644
--- a/drivers/mtd/nand/raw/omap2.c
+++ b/drivers/mtd/nand/raw/omap2.c
@@ -1669,6 +1669,11 @@ static const char * const nand_xfer_types[] = {
[NAND_OMAP_PREFETCH_IRQ] = "prefetch-irq",
};
+static void omap_put_elm_node(void *data)
+{
+ of_node_put(data);
+}
+
static int omap_get_dt_info(struct device *dev, struct omap_nand_info *info)
{
struct device_node *child = dev->of_node;
@@ -1691,6 +1696,10 @@ static int omap_get_dt_info(struct device *dev, struct omap_nand_info *info)
dev_dbg(dev, "ti,elm-id not in DT\n");
}
+ i = devm_add_action_or_reset(dev, omap_put_elm_node, info->elm_of_node);
+ if (i)
+ return i;
+
/* select ecc-scheme for NAND */
if (of_property_read_string(child, "ti,nand-ecc-opt", &s)) {
dev_err(dev, "ti,nand-ecc-opt not found\n");
base-commit: 2efb7a11f1aa4d2dc285fe2680cca22cb9f72f64