regmap: destroy mutex (if used) in regmap_exit()
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Mon, 28 Sep 2020 12:06:14 +0000 (14:06 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 28 Sep 2020 17:28:45 +0000 (18:28 +0100)
While not destroying mutexes doesn't lead to memory leaks, it's still
the correct thing to do for mutex debugging accounting.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20200928120614.23172-1-brgl@bgdev.pl
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/base/regmap/regmap.c

index a4d3d41f52214544b6d17a9e2aac59908793fa05..5a121bee530cbf0bb06c9706491eefd2bc97d09a 100644 (file)
@@ -1370,6 +1370,8 @@ void regmap_exit(struct regmap *map)
        }
        if (map->hwlock)
                hwspin_lock_free(map->hwlock);
+       if (map->lock == regmap_lock_mutex)
+               mutex_destroy(&map->mutex);
        kfree_const(map->name);
        kfree(map->patch);
        kfree(map);