summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2011-11-14 10:40:16 +0100
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-11-14 21:46:09 +0000
commit021cd616decb4e8a4b31f1f8c466a847e8c04e67 (patch)
tree94d59c03e8fd9b89148b76cf3cc18eda2ef05d87 /drivers/base
parentabbb18fb4ad7472ee2e1351f0ca12bce64cac143 (diff)
downloadop-kernel-dev-021cd616decb4e8a4b31f1f8c466a847e8c04e67.zip
op-kernel-dev-021cd616decb4e8a4b31f1f8c466a847e8c04e67.tar.gz
regmap: Fix memory leak in regcache_hw_init error path
Make sure reg_defaults_raw gets freed in case of an error. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/regcache.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 6ab9f03..7944626 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -61,8 +61,10 @@ static int regcache_hw_init(struct regmap *map)
map->reg_defaults = kmalloc(count * sizeof(struct reg_default),
GFP_KERNEL);
- if (!map->reg_defaults)
- return -ENOMEM;
+ if (!map->reg_defaults) {
+ ret = -ENOMEM;
+ goto err_free;
+ }
/* fill the reg_defaults */
map->num_reg_defaults = count;
@@ -77,6 +79,12 @@ static int regcache_hw_init(struct regmap *map)
}
return 0;
+
+err_free:
+ if (map->cache_free)
+ kfree(map->reg_defaults_raw);
+
+ return ret;
}
int regcache_init(struct regmap *map)
OpenPOWER on IntegriCloud