Skip to content

Commit

Permalink
regmap: debugfs: Fix a reversed if statement in regmap_debugfs_init()
Browse files Browse the repository at this point in the history
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: cffa4b2 ("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>
  • Loading branch information
Dan Carpenter authored and Mark Brown committed Jan 5, 2021
1 parent cffa4b2 commit f6bcb4c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/base/regmap/regmap-debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,7 @@ void regmap_debugfs_init(struct regmap *map)
}

if (!strcmp(name, "dummy")) {
if (!map->debugfs_name)
kfree(map->debugfs_name);

kfree(map->debugfs_name);
map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d",
dummy_index);
if (!map->debugfs_name)
Expand Down

0 comments on commit f6bcb4c

Please sign in to comment.