Use map->debugfs_name to store allocated debugfs name, so it would be freed in regmap_debugfs_exit().
Kmemleak reported: unreferenced object 0xffffffc0cf78cf00 (size 128): comm "swapper/0", pid 1, jiffies 4294669168 (age 89.152s) hex dump (first 32 bytes): 64 75 6d 6d 79 32 33 00 00 00 00 00 00 00 00 00 dummy23......... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<0000000027429160>] kmemleak_alloc+0x58/0x8c [<0000000081861ddf>] __kmalloc_track_caller+0x1dc/0x2bc [<00000000258a341f>] kvasprintf+0xd0/0x168 [<00000000f3243f27>] kasprintf+0xac/0xd8 [<000000005f585642>] regmap_debugfs_init+0x1a0/0x3b0 [<000000002c08b110>] __regmap_init+0x12b8/0x135c [<00000000f64bcddb>] __regmap_init_mmio_clk+0x70/0x84 [<000000009c8f06b5>] of_syscon_register+0x278/0x378 [<0000000087e6c121>] syscon_node_to_regmap+0x80/0xb0 Fixes: a430ab205d29 ("regmap: debugfs: Disambiguate dummy debugfs file name") Signed-off-by: Jeffy Chen <jeffy.c...@rock-chips.com> --- drivers/base/regmap/regmap-debugfs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c index e3e7b91cc421..5479a183248f 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c @@ -570,15 +570,15 @@ void regmap_debugfs_init(struct regmap *map, const char *name) map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s", devname, name); name = map->debugfs_name; + } else if (!map->dev) { + map->debugfs_name = kasprintf(GFP_KERNEL, "%s%d", + devname, dummy_index); + name = map->debugfs_name; + dummy_index++; } else { name = devname; } - if (!strcmp(name, "dummy")) { - name = kasprintf(GFP_KERNEL, "dummy%d", dummy_index); - dummy_index++; - } - map->debugfs = debugfs_create_dir(name, regmap_debugfs_root); if (!map->debugfs) { dev_warn(map->dev, "Failed to create debugfs directory\n"); -- 2.11.0