[PATCH v2 3/3] regmap: debugfs: Free map->debugfs_name when debugfs_create_dir() failed
From: Jeffy Chen
Date: Tue Mar 06 2018 - 06:04:33 EST
Free map->debugfs_name when debugfs_create_dir() failed to avoid memory
leak.
Signed-off-by: Jeffy Chen <jeffy.chen@xxxxxxxxxxxxxx>
---
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 5479a183248f..55e862a81e82 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -582,6 +582,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.11.0