* [PATCH] mtd: ubi: nvmem: put the nvmem-layout node after the check
@ 2026-11-29 17:11 Cong Nguyen
0 siblings, 0 replies; only message in thread
From: Cong Nguyen @ 2026-11-29 17:11 UTC (permalink / raw)
To: Richard Weinberger, Miquel Raynal
Cc: Zhihao Cheng, Vignesh Raghavendra, linux-mtd, linux-kernel
ubi_nvmem_add() calls of_get_child_by_name() only to see whether the
volume has an "nvmem-layout" node, and never drops the reference it gets.
Put the node right after the check.
Fixes: 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes")
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
drivers/mtd/ubi/nvmem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/ubi/nvmem.c b/drivers/mtd/ubi/nvmem.c
index 2dade9727cf2..05bf71f66b34 100644
--- a/drivers/mtd/ubi/nvmem.c
+++ b/drivers/mtd/ubi/nvmem.c
@@ -61,6 +61,7 @@ static int ubi_nvmem_reg_read(void *priv, unsigned int from,
static int ubi_nvmem_add(struct ubi_volume_info *vi)
{
struct device_node *np = dev_of_node(vi->dev);
+ struct device_node *layout;
struct nvmem_config config = {};
struct ubi_nvmem *unv;
int ret;
@@ -68,8 +69,10 @@ static int ubi_nvmem_add(struct ubi_volume_info *vi)
if (!np)
return 0;
- if (!of_get_child_by_name(np, "nvmem-layout"))
+ layout = of_get_child_by_name(np, "nvmem-layout");
+ if (!layout)
return 0;
+ of_node_put(layout);
if (WARN_ON_ONCE(vi->usable_leb_size <= 0) ||
WARN_ON_ONCE(vi->size <= 0))
--
2.25.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-29 17:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-29 17:11 [PATCH] mtd: ubi: nvmem: put the nvmem-layout node after the check Cong Nguyen
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®