[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1321263619-25891-3-git-send-email-lars@metafoo.de>
Date: Mon, 14 Nov 2011 10:40:17 +0100
From: Lars-Peter Clausen <lars@...afoo.de>
To: Mark Brown <broonie@...nsource.wolfsonmicro.com>
CC: Dimitris Papastamos <dp@...nsource.wolfsonmicro.com>,
<linux-kernel@...r.kernel.org>,
Lars-Peter Clausen <lars@...afoo.de>
Subject: [PATCH 3/5] regmap: Fix memory leak in regcache_init error path
Make sure all allocated memory gets freed again in case initializing the cache
failed.
Signed-off-by: Lars-Peter Clausen <lars@...afoo.de>
---
drivers/base/regmap/regcache.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 7944626..27fae58 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -144,9 +144,18 @@ int regcache_init(struct regmap *map)
if (map->cache_ops->init) {
dev_dbg(map->dev, "Initializing %s cache\n",
map->cache_ops->name);
- return map->cache_ops->init(map);
+ ret = map->cache_ops->init(map);
+ if (ret)
+ goto err_free;
}
return 0;
+
+err_free:
+ kfree(map->reg_defaults);
+ if (map->cache_free)
+ kfree(map->reg_defaults_raw);
+
+ return ret;
}
void regcache_exit(struct regmap *map)
--
1.7.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists