All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] nvmem: layouts: sl28vpd: fix device_node reference leak in error path
@ 2026-08-11 12:55 Leo Cheng
  2026-08-11 14:38 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Leo Cheng @ 2026-08-11 12:55 UTC (permalink / raw)
  To: Srinivas Kandagatla, Michael Walle, Miquel Raynal; +Cc: linux-kernel

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>
---
 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 e93b020b0..79de1e694 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.43.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] nvmem: layouts: sl28vpd: fix device_node reference leak in error path
  2026-08-11 12:55 [PATCH 1/2] nvmem: layouts: sl28vpd: fix device_node reference leak in error path Leo Cheng
@ 2026-08-11 14:38 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2026-08-11 14:38 UTC (permalink / raw)
  To: Leo Cheng; +Cc: Srinivas Kandagatla, Michael Walle, linux-kernel

On 11/08/2026 at 20:55:48 +08, Leo Cheng <leo-cheng@vip.qq.com> wrote:

> 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: Miquel Raynal <miquel.raynal@bootlin.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-11 14:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 12:55 [PATCH 1/2] nvmem: layouts: sl28vpd: fix device_node reference leak in error path Leo Cheng
2026-08-11 14:38 ` Miquel Raynal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.