summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2021-01-05 14:42:29 +0300
committerMark Brown <broonie@kernel.org>2021-01-05 14:34:41 +0000
commitf6bcb4c7f366905b66ce8ffca7190118244bb642 (patch)
tree5a084819bfc49a1fc55b52dd41b02e6fc4ec7304 /drivers/base
parentcffa4b2122f5f3e53cf3d529bbc74651f95856d5 (diff)
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: cffa4b2122f5 ("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>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/regmap-debugfs.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index bf03cd343be2..ff2ee87987c7 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -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)