[PATCH] regmap: debugfs: Free map->debugfs_name when debugfs_create_dir() failed
From: Jeffy Chen
Date: Tue Mar 06 2018 - 06:04:03 EST
Free map->debugfs_name when debugfs_create_dir() failed to avoid memory
leak.
Signed-off-by: Jeffy Chen <jeffy.chen@xxxxxxxxxxxxxx>
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
---
drivers/base/regmap/regmap-debugfs.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index dd3a16894e3c..c84f5ceb015a 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -584,6 +584,9 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
if (!map->debugfs) {
dev_warn(map->dev, "Failed to create debugfs directory\n");
+
+ kfree(map->debugfs_name);
+ map->debugfs_name = NULL;
return;
}
--
2.16.2