nvmem: layouts: sl28vpd: Fix np reference leak in sl28vpd_add_cells()
Subsystems (3)
PATCH 1/1 nvmem: layouts: sl28vpd: Fix np reference leak in sl28vpd_add_cells()
of_get_child_by_name() returns a node with an elevated reference count. nvmem_add_one_cell() only takes ownership of that reference on success, so the caller must drop it when the call fails. Add the missing of_node_put() before returning so that info.np is not leaked.
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.34.1
Michael Walle
maintainerQuoted 8 lines · Wentao Liang
of_get_child_by_name()returns a node with an elevated reference count.nvmem_add_one_cell()only takes ownership of that reference on success, so the caller must drop it when the call fails. Add the missingof_node_put()before returning so that info.np is not leaked.Fixes d9fae023fe86 ("nvmem: layouts: sl28vpd: Add new layout driver")Signed-off-by Wentao Liang <[email protected]>
There was already a patch fixing this:
https://lore.kernel.org/r/[email protected]/
-michael