Skip to contentSkip to conversation

fix: nvmem: onie_tlv_add_cells: fix device_node reference leak on nvmem_add_one_cell failure

PATCH In review WenTao Liang 1 participant 2 messages Jun 26 – Jun 28

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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.

Fixes d3c0d12f6474 ("nvmem: layouts: onie-tlv: Add new layout driver")
---
 drivers/nvmem/layouts/onie-tlv.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvmem/layouts/onie-tlv.c +1 -0
index 0967a32319a2..3d77680f089b 100644
@@ -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)
#1 lore raw
Quoted 33 lines

2026年6月26日 23:41,WenTao Liang <[email protected]> 写道:

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.

Fixes d3c0d12f6474 ("nvmem: layouts: onie-tlv: Add new layout driver")

---
drivers/nvmem/layouts/onie-tlv.c | 1 +

1 file changed, 1 insertion(+)
drivers/nvmem/layouts/onie-tlv.c +1 -0
index 0967a32319a2..3d77680f089b 100644
@@ -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