From: Cong Nguyen <congnt264@gmail.com>
To: Richard Weinberger <richard@nod.at>,
Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Zhihao Cheng <chengzhihao1@huawei.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] mtd: ubi: nvmem: put the nvmem-layout node after the check
Date: Mon, 30 Nov 2026 00:11:28 +0700 [thread overview]
Message-ID: <20261129171128.468311-1-congnt264@gmail.com> (raw)
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
reply other threads:[~2026-11-29 17:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261129171128.468311-1-congnt264@gmail.com \
--to=congnt264@gmail.com \
--cc=chengzhihao1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.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®