Re: [PATCH] regmap: debugfs: potentially duplicate the name string of the config

From: Dafna Hirschfeld
Date: Tue Sep 08 2020 - 15:01:35 EST


Hi, thank you for the fast review,

Am 08.09.20 um 17:35 schrieb Mark Brown:
On Tue, Sep 08, 2020 at 05:28:59PM +0200, Dafna Hirschfeld wrote:
In function regmap_debugfs_init the name of the regmap_config is assigned
in a node of regmap_debugfs_early_list to be used later after regmap
is initialized. It is unknown how and when the name is allocated and freed.
Therefore the name should be copied to the node using 'kstrdup_const'.

It does not follow that the name should be copied, it equally follows
(and is expected by the API given that the common case is that the name
is a static string assigned at build time) that the caller should not
free the string while the regmap is active.

I see that the same copy is already done in function __regmap_init in drivers/base/regmap/regmap.c
added in patch 8253bb3f82554 "regmap: potentially duplicate the name string stored in regmap"
so I thought I'll do the same.


This fixes an error
"debugfs: Directory 'dummy-' with parent 'regmap' already present!"
where the name was freed in function of_syscon_register before
it was accessed.

Fix the caller. It is *very* much unclear to me why a syscon would be
assigning a name for a regmap it creates in the first place.

I'll have a deeper look.

Thanks,
Dafna