From: srini@kernel.org
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, Leo Cheng <leo-cheng@vip.qq.com>,
Michael Walle <mwalle@kernel.org>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Srinivas Kandagatla <srini@kernel.org>
Subject: [PATCH 2/4] nvmem: layouts: sl28vpd: fix device_node reference leak in error path
Date: Fri, 2 Oct 2026 11:13:27 +0100 [thread overview]
Message-ID: <20261002101329.1084348-3-srini@kernel.org> (raw)
In-Reply-To: <20261002101329.1084348-1-srini@kernel.org>
From: Leo Cheng <leo-cheng@vip.qq.com>
sl28vpd_add_cells() takes a reference on the child node via
of_get_child_by_name() for each entry and passes it to
nvmem_add_one_cell() as info.np. On success the created cell entry
adopts that reference and releases it later via of_node_put() when the
entry is torn down; nvmem_add_one_cell() does not take its own
reference. On failure it does not consume the reference either, so the
caller still owns it, but the error path only puts layout_np before
returning, leaking the child node reference.
Put info.np on the error path as well. of_node_put(NULL) is a no-op, so
this is safe even when of_get_child_by_name() returned NULL.
Fixes: d9fae023fe86 ("nvmem: layouts: sl28vpd: Add new layout driver")
Signed-off-by: Leo Cheng <leo-cheng@vip.qq.com>
Reviewed-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
---
drivers/nvmem/layouts/sl28vpd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvmem/layouts/sl28vpd.c b/drivers/nvmem/layouts/sl28vpd.c
index e93b020b0836..79de1e6947d0 100644
--- a/drivers/nvmem/layouts/sl28vpd.c
+++ b/drivers/nvmem/layouts/sl28vpd.c
@@ -126,6 +126,7 @@ static int sl28vpd_add_cells(struct nvmem_layout *layout)
ret = nvmem_add_one_cell(nvmem, &info);
if (ret) {
+ of_node_put(info.np);
of_node_put(layout_np);
return ret;
}
--
2.53.0
next prev parent reply other threads:[~2026-10-02 10:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 10:13 [PATCH 0/4] nvmem: fixes for 7.3 srini
2026-10-02 10:13 ` [PATCH 1/4] nvmem: rockchip-otp: Serialize reads srini
2026-10-02 10:13 ` srini [this message]
2026-10-02 10:13 ` [PATCH 3/4] nvmem: layouts: onie-tlv: fix device_node reference leak in error path srini
2026-10-02 10:13 ` [PATCH 4/4] nvmem: core: Fix OOB read for bit offsets of more than one byte srini
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=20261002101329.1084348-3-srini@kernel.org \
--to=srini@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=leo-cheng@vip.qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=mwalle@kernel.org \
/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®