mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeffy Chen <jeffy.chen@rock-chips.com>
To: linux-kernel@vger.kernel.org
Cc: Jeffy Chen <jeffy.chen@rock-chips.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mark Brown <broonie@kernel.org>
Subject: [PATCH v2 2/3] regmap: debugfs: Fix kmemleak in regmap_debugfs_init
Date: Tue,  6 Mar 2018 19:04:02 +0800	[thread overview]
Message-ID: <20180306110403.14438-2-jeffy.chen@rock-chips.com> (raw)
In-Reply-To: <20180306110403.14438-1-jeffy.chen@rock-chips.com>

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.chen@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

  reply	other threads:[~2018-03-06 11:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-06 11:04 [PATCH v2 1/3] mfd: syscon: Set name of regmap_config Jeffy Chen
2018-03-06 11:04 ` Jeffy Chen [this message]
2018-03-06 12:59   ` [PATCH v2 2/3] regmap: debugfs: Fix kmemleak in regmap_debugfs_init Mark Brown
2018-03-07 10:56     ` JeffyChen
2018-03-06 11:04 ` [PATCH v2 3/3] regmap: debugfs: Free map->debugfs_name when debugfs_create_dir() failed Jeffy Chen
2018-03-07 14:15   ` Applied "regmap: debugfs: Free map->debugfs_name when debugfs_create_dir() failed" to the regmap tree Mark Brown
2018-03-06 14:58 ` [PATCH v2 1/3] mfd: syscon: Set name of regmap_config JeffyChen
2018-03-07 10:20   ` Mark Brown
2018-03-07 10:50     ` JeffyChen
2018-03-07 10:57       ` Mark Brown
2018-03-07 16:54         ` Lee Jones
2018-03-07 16:57           ` Mark Brown
2018-03-12 14:07             ` Lee Jones
2018-03-12 16:11               ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180306110403.14438-2-jeffy.chen@rock-chips.com \
    --to=jeffy.chen@rock-chips.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®