regmap: Also protect hwspinlock in error handling path
[sfrench/cifs-2.6.git] / drivers / base / regmap / regmap.c
index ff6ef6a579c6151bdc799447b6ccdad8928d1e2b..5ff549fa880becc39a8aa53b324a70744711bfa2 100644 (file)
@@ -1116,7 +1116,8 @@ err_range:
        regmap_range_exit(map);
        kfree(map->work_buf);
 err_hwlock:
        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:
 err_map:
        kfree(map);
 err: