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: cffa4b2122 ("regmap: debugfs: Fix a memory leak when calling regmap_attach_dev")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/X/RQpfAwRdLg0GqQ@mwanda
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Dan Carpenter 2021-01-05 14:42:29 +03:00 committed by Mark Brown
parent cffa4b2122
commit f6bcb4c7f3
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 1 additions and 3 deletions

View File

@ -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)