Skip to contentSkip to conversation

regmap: Fix memory leak in regmap_init error path

PATCH Applied Lars-Peter Clausen 2 participants 2 messages Nov 10, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regmap: Fix memory leak in regmap_init error path

If regcache initialization fails regmap_init will currently exit without freeing work_buf.

---
 drivers/base/regmap/regmap.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/base/regmap/regmap.c +3 -1
index 3e30d16..b08df85 100644
@@ -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:
Signature · 1 line
1.7.7.1