* [PATCH] regmap: debugfs: Fix name collision without atomic operations
@ 2025-03-04 12:22 Zxyan Zhu
2025-03-04 13:23 ` Mark Brown
2025-03-04 14:10 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Zxyan Zhu @ 2025-03-04 12:22 UTC (permalink / raw)
To: broonie; +Cc: gregkh, rafael, dakr, linux-kernel, Zxyan Zhu
A global variable caused debugfs name conflicts during re-entry,
leading to creation failures. Use atomic operations to ensure safe
and unique naming.
Signed-off-by: Zxyan Zhu <zxyan20@163.com>
---
drivers/base/regmap/regmap-debugfs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index fb84cda92a75..914fc032861d 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -20,7 +20,7 @@ struct regmap_debugfs_node {
struct list_head link;
};
-static unsigned int dummy_index;
+static atomic_t dummy_index = ATOMIC_INIT(0);
static struct dentry *regmap_debugfs_root;
static LIST_HEAD(regmap_debugfs_early_list);
static DEFINE_MUTEX(regmap_debugfs_early_lock);
@@ -596,11 +596,11 @@ void regmap_debugfs_init(struct regmap *map)
if (!strcmp(name, "dummy")) {
kfree(map->debugfs_name);
map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d",
- dummy_index);
+ atomic_read(&dummy_index));
if (!map->debugfs_name)
return;
name = map->debugfs_name;
- dummy_index++;
+ atomic_inc(&dummy_index);
}
map->debugfs = debugfs_create_dir(name, regmap_debugfs_root);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] regmap: debugfs: Fix name collision without atomic operations
2025-03-04 12:22 [PATCH] regmap: debugfs: Fix name collision without atomic operations Zxyan Zhu
@ 2025-03-04 13:23 ` Mark Brown
2025-03-04 14:10 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2025-03-04 13:23 UTC (permalink / raw)
To: Zxyan Zhu; +Cc: gregkh, rafael, dakr, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 670 bytes --]
On Tue, Mar 04, 2025 at 08:22:21PM +0800, Zxyan Zhu wrote:
> A global variable caused debugfs name conflicts during re-entry,
> leading to creation failures. Use atomic operations to ensure safe
> and unique naming.
This doesn't help at all AFAICT? IIRC this code was relying on some
higher level locking but ICBW.
> - dummy_index);
> + atomic_read(&dummy_index));
Here we do an atomic read...
> if (!map->debugfs_name)
> return;
> name = map->debugfs_name;
> - dummy_index++;
> + atomic_inc(&dummy_index);
...then later we do an atomic increment so something else could also
have come in and done an atomic read before we do the increment.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regmap: debugfs: Fix name collision without atomic operations
2025-03-04 12:22 [PATCH] regmap: debugfs: Fix name collision without atomic operations Zxyan Zhu
2025-03-04 13:23 ` Mark Brown
@ 2025-03-04 14:10 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2025-03-04 14:10 UTC (permalink / raw)
To: Zxyan Zhu; +Cc: broonie, rafael, dakr, linux-kernel
On Tue, Mar 04, 2025 at 08:22:21PM +0800, Zxyan Zhu wrote:
> A global variable caused debugfs name conflicts during re-entry,
What global variable?
> leading to creation failures. Use atomic operations to ensure safe
> and unique naming.
Naming of what, the variables or the debugfs file?
confused,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-04 14:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-04 12:22 [PATCH] regmap: debugfs: Fix name collision without atomic operations Zxyan Zhu
2025-03-04 13:23 ` Mark Brown
2025-03-04 14:10 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox