Re: [PATCH] regmap: debugfs: Fix name collision without atomic operations

From: Mark Brown
Date: Tue Mar 04 2025 - 08:23:23 EST


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: signature.asc
Description: PGP signature