mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nvmem: layouts: sl28vpd: Fix np reference leak in sl28vpd_add_cells()
@ 2026-09-17 12:37 Wentao Liang
  2026-09-17 13:52 ` Michael Walle
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-17 12:37 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, miquel.raynal, mwalle, srini, Wentao Liang, stable

of_get_child_by_name() returns a node with an elevated reference count.
nvmem_add_one_cell() only takes ownership of that reference on success,
so the caller must drop it when the call fails. Add the missing
of_node_put() before returning so that info.np is not leaked.

Fixes: d9fae023fe86 ("nvmem: layouts: sl28vpd: Add new layout driver")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 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.34.1


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

* Re: [PATCH] nvmem: layouts: sl28vpd: Fix np reference leak in sl28vpd_add_cells()
  2026-09-17 12:37 [PATCH] nvmem: layouts: sl28vpd: Fix np reference leak in sl28vpd_add_cells() Wentao Liang
@ 2026-09-17 13:52 ` Michael Walle
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Walle @ 2026-09-17 13:52 UTC (permalink / raw)
  To: Wentao Liang, gregkh; +Cc: linux-kernel, miquel.raynal, srini, stable

[-- Attachment #1: Type: text/plain, Size: 634 bytes --]

On Thu Sep 17, 2026 at 2:37 PM CEST, Wentao Liang wrote:
> of_get_child_by_name() returns a node with an elevated reference count.
> nvmem_add_one_cell() only takes ownership of that reference on success,
> so the caller must drop it when the call fails. Add the missing
> of_node_put() before returning so that info.np is not leaked.
>
> Fixes: d9fae023fe86 ("nvmem: layouts: sl28vpd: Add new layout driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

There was already a patch fixing this:

https://lore.kernel.org/r/tencent_65156571568C9E4076E52D1825CC5F476A08@qq.com/

-michael

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]

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

end of thread, other threads:[~2026-09-17 13:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 12:37 [PATCH] nvmem: layouts: sl28vpd: Fix np reference leak in sl28vpd_add_cells() Wentao Liang
2026-09-17 13:52 ` Michael Walle

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®