Re: [PATCH v2] regmap: debugfs: Free debugfs_name buffer after usage

From: Mark Brown
Date: Fri Jan 07 2022 - 08:27:24 EST


On Thu, Jan 06, 2022 at 11:22:32PM -0300, Fabio Estevam wrote:
> On Thu, Jan 6, 2022 at 6:13 PM Fabio Estevam <festevam@xxxxxxxxx> wrote:

> > > Before we try to reinitialise debugfs for the new name seems like the
> > > obvious place.

> > I am afraid I am not enough familiar with regmap to fix this problem.

> > If you could please submit a patch, I will be glad to test it.

> I tried this change:
> @@ -581,6 +581,8 @@ void regmap_debugfs_init(struct regmap *map)
> if (map->dev)
> devname = dev_name(map->dev);
>
> + regmap_debugfs_exit(map);
> +

I would have expected this to be prior to the call to _init() rather
than actually in the call to _init() but OTOH this should work fine so
meh.

> It does avoid the 'already present' error and I see that
> /sys/kernel/debug/regmap/20e0000.pinctrl-gpr
> is present, but /sys/kernel/debug/regmap/20e0000.pinctrl-gpr is not.
> Not sure if this is the desired behavior.

Yes, that's what we're looking for (assuming the second of those names
should be the dummy name) - that means that the old debugfs file is not
hanging around and so won't be stuck there pointing at a deallocated
regmap if the regmap gets freed for some reason.

Attachment: signature.asc
Description: PGP signature