Re: [PATCH] fix: nvmem: onie_tlv_add_cells: fix device_node reference leak on nvmem_add_one_cell failure

From: WenTao Liang

Date: Sun Jun 28 2026 - 00:03:37 EST




> 2026年6月26日 23:41,WenTao Liang <vulab@xxxxxxxxxxx> 写道:
>
> of_get_child_by_name acquires a child device_node reference stored in
> cell.np. When nvmem_add_one_cell fails, the error path calls
> of_node_put(layout) but fails to call of_node_put(cell.np) on the child
> node, causing a device_node reference leak.
>
> Add of_node_put(cell.np) in the error path to properly release the child
> node reference when cell registration fails.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: d3c0d12f6474 ("nvmem: layouts: onie-tlv: Add new layout driver")
> Signed-off-by: WenTao Liang <vulab@xxxxxxxxxxx>
> ---
> 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.39.5 (Apple Git-154)

Please ignore this patch. I will resend a proper version after
learning the kernel submission process.

Apologies for the noise.

Best regards,
WenTao Liang