提交 0802d69e 编写于 作者: D Dan Carpenter 提交者: Zheng Zengkai

regmap: debugfs: Fix a reversed if statement in regmap_debugfs_init()

stable inclusion
from stable-5.10.8
commit 75e5e51acf59ff7436605ef91f486f9543534f9e
bugzilla: 47450

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

commit f6bcb4c7 upstream.

This code will leak "map->debugfs_name" because the if statement is
reversed so it only frees NULL pointers instead of non-NULL.  In
fact the if statement is not required and should just be removed
because kfree() accepts NULL pointers.

Fixes: cffa4b21 ("regmap: debugfs: Fix a memory leak when calling regmap_attach_dev")
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/X/RQpfAwRdLg0GqQ@mwandaSigned-off-by: NMark Brown <broonie@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 8d3ffeaa
...@@ -594,9 +594,7 @@ void regmap_debugfs_init(struct regmap *map) ...@@ -594,9 +594,7 @@ void regmap_debugfs_init(struct regmap *map)
} }
if (!strcmp(name, "dummy")) { if (!strcmp(name, "dummy")) {
if (!map->debugfs_name) kfree(map->debugfs_name);
kfree(map->debugfs_name);
map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d", map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d",
dummy_index); dummy_index);
if (!map->debugfs_name) if (!map->debugfs_name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册