Skip to contentSkip to conversation

fix: nvmem: sl28vpd_add_cells: fix missing of_node_put for info.np 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: sl28vpd_add_cells: fix missing of_node_put for info.np on nvmem_add_one_cell failure

In sl28vpd_add_cells(), of_get_child_by_name() acquires a reference for
info.np inside the loop. On success, nvmem_add_one_cell() consumes the reference. However, when nvmem_add_one_cell() fails, the function releases layout_np via of_node_put() but does not call of_node_put(info.np), leaking the device_node reference.

Add of_node_put(info.np) before returning error to fix the leak.

Fixes d9fae023fe86 ("nvmem: layouts: sl28vpd: Add new layout driver")
---
 drivers/nvmem/layouts/sl28vpd.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvmem/layouts/sl28vpd.c +1 -0
index e93b020b0836..79de1e6947d0 100644
@@ -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;
 		}
Signature · 1 line
2.39.5 (Apple Git-154)
#1 lore raw
Quoted 33 lines

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

In sl28vpd_add_cells(), of_get_child_by_name() acquires a reference for
info.np inside the loop. On success, nvmem_add_one_cell() consumes the reference. However, when nvmem_add_one_cell() fails, the function releases layout_np via of_node_put() but does not call of_node_put(info.np), leaking the device_node reference.

Add of_node_put(info.np) before returning error to fix the leak.

Fixes d9fae023fe86 ("nvmem: layouts: sl28vpd: Add new layout driver")

---
drivers/nvmem/layouts/sl28vpd.c | 1 +

1 file changed, 1 insertion(+)
drivers/nvmem/layouts/sl28vpd.c +1 -0
index e93b020b0836..79de1e6947d0 100644
@@ -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;
 		}
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