regmap: Fix memory leak in regmap_init error path
Lars-Peter Clausen [Thu, 10 Nov 2011 17:15:15 +0000 (18:15 +0100)]
If regcache initialization fails regmap_init will currently exit without
freeing work_buf.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit 58072cbfc522c2520e34333a53c8f17bb1adb1a0)

Change-Id: I55877ab14da86fbc479a0418c7f5371486574525
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/87553

drivers/base/regmap/regmap.c

index e9eda8c..7f0930d 100644 (file)
@@ -229,12 +229,14 @@ struct regmap *regmap_init(struct device *dev,
 
        ret = regcache_init(map);
        if (ret < 0)
-               goto err_map;
+               goto err_free_workbuf;
 
        regmap_debugfs_init(map);
 
        return map;
 
+err_free_workbuf:
+       kfree(map->work_buf);
 err_map:
        kfree(map);
 err: