Skip to content

Commit f6bcb4c

Browse files
Dan Carpenterbroonie
authored andcommitted
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: cffa4b2 ("regmap: debugfs: Fix a memory leak when calling regmap_attach_dev") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/X/RQpfAwRdLg0GqQ@mwanda Signed-off-by: Mark Brown <[email protected]>
1 parent cffa4b2 commit f6bcb4c

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/base/regmap/regmap-debugfs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,7 @@ void regmap_debugfs_init(struct regmap *map)
594594
}
595595

596596
if (!strcmp(name, "dummy")) {
597-
if (!map->debugfs_name)
598-
kfree(map->debugfs_name);
599-
597+
kfree(map->debugfs_name);
600598
map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d",
601599
dummy_index);
602600
if (!map->debugfs_name)

0 commit comments

Comments
 (0)