From: Mark Brown Date: Fri, 3 Nov 2017 19:50:20 +0000 (+0000) Subject: regmap: Also protect hwspinlock in error handling path X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=267f3e4f18f1ccf9e8cf72c3b4689df03025516d;p=linux.git regmap: Also protect hwspinlock in error handling path The previous patch to allow the hwspinlock code to be disabled missed handling the free in the error path, do so using the better IS_ENABLED() pattern as suggested by Baolin. While we're at it also check that we have a hardware spinlock before freeing it - the core code reports an error when freeing an invalid lock. Suggested-by: Baolin Wang Signed-off-by: Mark Brown --- diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index ff6ef6a579c61..5ff549fa880be 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1116,7 +1116,8 @@ err_range: regmap_range_exit(map); kfree(map->work_buf); err_hwlock: - hwspin_lock_free(map->hwlock); + if (IS_ENABLED(REGMAP_HWSPINLOCK) && map->hwlock) + hwspin_lock_free(map->hwlock); err_map: kfree(map); err: