提交 021cd616 编写于 作者: L Lars-Peter Clausen 提交者: Mark Brown

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: NLars-Peter Clausen <lars@metafoo.de>
Acked-by: NDimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 abbb18fb
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册