mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nvmem: layouts: onie-tlv: Fix np reference leak in onie_tlv_add_cells()
@ 2026-09-17 12:35 Wentao Liang
  2026-09-18 21:40 ` Srinivas Kandagatla
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-17 12:35 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, miquel.raynal, 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 cell.np is not leaked.

Fixes: d3c0d12f6474 ("nvmem: layouts: onie-tlv: Add new layout driver")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/nvmem/layouts/onie-tlv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvmem/layouts/onie-tlv.c b/drivers/nvmem/layouts/onie-tlv.c
index 0967a32319a2..3d77680f089b 100644
--- a/drivers/nvmem/layouts/onie-tlv.c
+++ b/drivers/nvmem/layouts/onie-tlv.c
@@ -128,6 +128,7 @@ static int onie_tlv_add_cells(struct device *dev, struct nvmem_device *nvmem,
 
 		ret = nvmem_add_one_cell(nvmem, &cell);
 		if (ret) {
+			of_node_put(cell.np);
 			of_node_put(layout);
 			return ret;
 		}
-- 
2.34.1


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

* Re: [PATCH] nvmem: layouts: onie-tlv: Fix np reference leak in onie_tlv_add_cells()
  2026-09-17 12:35 [PATCH] nvmem: layouts: onie-tlv: Fix np reference leak in onie_tlv_add_cells() Wentao Liang
@ 2026-09-18 21:40 ` Srinivas Kandagatla
  0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Kandagatla @ 2026-09-18 21:40 UTC (permalink / raw)
  To: Wentao Liang, gregkh; +Cc: linux-kernel, miquel.raynal, srini, stable



On 9/17/26 1:35 PM, 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 cell.np is not leaked.
> 

Same comment, do not waste time with duplicate patches.

--srini

> Fixes: d3c0d12f6474 ("nvmem: layouts: onie-tlv: Add new layout driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/nvmem/layouts/onie-tlv.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/nvmem/layouts/onie-tlv.c b/drivers/nvmem/layouts/onie-tlv.c
> index 0967a32319a2..3d77680f089b 100644
> --- a/drivers/nvmem/layouts/onie-tlv.c
> +++ b/drivers/nvmem/layouts/onie-tlv.c
> @@ -128,6 +128,7 @@ static int onie_tlv_add_cells(struct device *dev, struct nvmem_device *nvmem,
>  
>  		ret = nvmem_add_one_cell(nvmem, &cell);
>  		if (ret) {
> +			of_node_put(cell.np);
>  			of_node_put(layout);
>  			return ret;
>  		}


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

end of thread, other threads:[~2026-09-18 21:40 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:35 [PATCH] nvmem: layouts: onie-tlv: Fix np reference leak in onie_tlv_add_cells() Wentao Liang
2026-09-18 21:40 ` Srinivas Kandagatla

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®