提交 9bf98823 编写于 作者: D Dan Carpenter 提交者: Zheng Zengkai

nvmem: core: Fix a resource leak on error in nvmem_add_cells_from_of()

stable inclusion
from stable-5.10.20
commit 0422b93c4bfb2a4d2cd5402f95591cc323fe577c
bugzilla: 50608

--------------------------------

[ Upstream commit 72e008ce ]

This doesn't call of_node_put() on the error path so it leads to a
memory leak.

Fixes: 0749aa25 ("nvmem: core: fix regression in of_nvmem_cell_get()")
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210129171430.11328-2-srinivas.kandagatla@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 6ac2e354
......@@ -576,6 +576,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
cell->name, nvmem->stride);
/* Cells already added will be freed later. */
kfree_const(cell->name);
of_node_put(cell->np);
kfree(cell);
return -EINVAL;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册