Commit f6bcb4c7 authored by Dan Carpenter's avatar Dan Carpenter Committed by Mark Brown

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

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/X/RQpfAwRdLg0GqQ@mwandaSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent cffa4b21
......@@ -594,9 +594,7 @@ void regmap_debugfs_init(struct regmap *map)
}
if (!strcmp(name, "dummy")) {
if (!map->debugfs_name)
kfree(map->debugfs_name);
map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d",
dummy_index);
if (!map->debugfs_name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment