fix: nvmem: onie_tlv_add_cells: fix device_node reference leak on nvmem_add_one_cell failure
Subsystems (3)
PATCH 1/1 fix: nvmem: onie_tlv_add_cells: fix device_node reference leak on nvmem_add_one_cell failure
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.
--- drivers/nvmem/layouts/onie-tlv.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvmem/layouts/onie-tlv.c +1 -0
@@ -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; }
Signature · 1 line
2.39.5 (Apple Git-154)
Quoted 33 lines
2026年6月26日 23:41,WenTao Liang <[email protected]> 写道:
of_get_child_by_nameacquires a childdevice_nodereference stored in
cell.np. Whennvmem_add_one_cellfails, the error path callsof_node_put(layout)but fails to callof_node_put(cell.np)on the child node, causing adevice_nodereference leak.Add
of_node_put(cell.np)in the error path to properly release the child
node reference when cell registration fails.Fixes d3c0d12f6474 ("nvmem: layouts: onie-tlv: Add new layout driver")Signed-off-by WenTao Liang <[email protected]>---
drivers/nvmem/layouts/onie-tlv.c| 1 +1 file changed, 1 insertion(+)drivers/nvmem/layouts/onie-tlv.c +1
-0@@ -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; }Signature · 1 line
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