From: Fabio Estevam <festevam@gmail.com>
To: broonie@kernel.org
Cc: matthias.schiffer@ew.tq-group.com, linux-kernel@vger.kernel.org,
Fabio Estevam <festevam@gmail.com>
Subject: [PATCH v2] regmap: debugfs: Free debugfs_name buffer after usage
Date: Thu, 6 Jan 2022 14:50:19 -0300 [thread overview]
Message-ID: <20220106175019.3116389-1-festevam@gmail.com> (raw)
The following error message is seen when booting an imx6q-sabresd:
debugfs: Directory 'dummy-iomuxc-gpr@20e0000' with parent 'regmap' already present!
The reason for the duplicate name is that map->debugfs_name is never freed,
which can cause a directory to be created with the same name used in the
previous debugfs entry allocation.
Fix this problem by freeing map->debugfs_name and setting it to NULL
after its usage.
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
Changes since v1:
- Avoid use after free (Mark).
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 ad684d37c2da..e1017ca65be0 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -605,6 +605,9 @@ void regmap_debugfs_init(struct regmap *map)
map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
+ kfree(map->debugfs_name);
+ map->debugfs_name = NULL;
+
debugfs_create_file("name", 0400, map->debugfs,
map, ®map_name_fops);
--
2.25.1
next reply other threads:[~2022-01-06 17:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-06 17:50 Fabio Estevam [this message]
2022-01-06 18:33 ` Mark Brown
2022-01-06 19:27 ` Fabio Estevam
2022-01-06 20:05 ` Mark Brown
2022-01-06 21:13 ` Fabio Estevam
2022-01-07 2:22 ` Fabio Estevam
2022-01-07 13:27 ` Mark Brown
2022-01-07 14:48 ` Fabio Estevam
2022-01-07 14:52 ` 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=20220106175019.3116389-1-festevam@gmail.com \
--to=festevam@gmail.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthias.schiffer@ew.tq-group.com \
/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
Powered by JetHome