fix: nvmem: sl28vpd_add_cells: fix missing of_node_put for info.np on nvmem_add_one_cell failure
Subsystems (3)
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.
--- drivers/nvmem/layouts/sl28vpd.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvmem/layouts/sl28vpd.c +1 -0
@@ -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)
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, whennvmem_add_one_cell()fails, the function releaseslayout_npviaof_node_put()but does not callof_node_put(info.np), leaking thedevice_nodereference.Add
of_node_put(info.np)before returning error to fix the leak.Fixes d9fae023fe86 ("nvmem: layouts: sl28vpd: Add new layout driver")Signed-off-by WenTao Liang <[email protected]>---
drivers/nvmem/layouts/sl28vpd.c| 1 +1 file changed, 1 insertion(+)drivers/nvmem/layouts/sl28vpd.c +1
-0@@ -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