Re: [PATCH] regmap: debugfs: Fix a boot time crash with early regmapinit

From: Tero Kristo
Date: Thu Oct 24 2013 - 08:03:21 EST


On 10/24/2013 12:18 PM, Mark Brown wrote:
On Thu, Oct 24, 2013 at 12:07:48PM +0300, Tero Kristo wrote:

+ if (!regmap_debugfs_root) {
+ struct regmap_debugfs_node *node;
+ node = kzalloc(sizeof(*node), GFP_KERNEL);
+ if (!node)
+ return;
+ node->map = map;
+ node->name = name;
+ list_add(&node->link, &regmap_debugfs_early);
+ return;
+ }
+

init is somewhat parallel so I'd be happier if we locked the list to
make sure that we don't corrupt the list.

Ok, I added a mutex for protection (later registration might take some time so didn't want to use spinlock.)

We also need something to handle removal of items from the list if the
regmap is destroyed prior to the initcall running (for example in error
handling cases), otherwise we could end up creating debugfs files
pointing at devices that no longer exist.

Added cleanup for the list in the regmap_debugfs_exit() call. Sending v2 shortly.

-Tero
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/