From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>,
<linux-kernel@vger.kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 2/5] regmap: Fix memory leak in regcache_hw_init error path
Date: Mon, 14 Nov 2011 10:40:16 +0100 [thread overview]
Message-ID: <1321263619-25891-2-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1321263619-25891-1-git-send-email-lars@metafoo.de>
Make sure reg_defaults_raw gets freed in case of an error.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/base/regmap/regcache.c | 12 ++++++++++--
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)
--
1.7.7.1
next prev parent reply other threads:[~2011-11-14 9:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-14 9:40 [PATCH 1/5] regmap: return ERR_PTR instead of NULL in regmap_init Lars-Peter Clausen
2011-11-14 9:40 ` Lars-Peter Clausen [this message]
2011-11-14 21:45 ` [PATCH 2/5] regmap: Fix memory leak in regcache_hw_init error path Mark Brown
2011-11-14 9:40 ` [PATCH 3/5] regmap: Fix memory leak in regcache_init " Lars-Peter Clausen
2011-11-14 21:45 ` Mark Brown
2011-11-14 9:40 ` [PATCH 4/5] regmap: Do not call regcache_exit from regcache_rbtree_init " Lars-Peter Clausen
2011-11-14 9:40 ` [PATCH 5/5] regmap: Do not call regcache_exit from regcache_lzo_init " Lars-Peter Clausen
2011-11-14 15:45 ` Dimitris Papastamos
2011-11-14 21:43 ` Mark Brown
2011-11-15 12:34 ` [PATCH 1/2] regmap: Do not call regcache_exit from regcache_rbtree_init " Lars-Peter Clausen
2011-11-15 12:34 ` [PATCH 2/2] regmap: Do not call regcache_exit from regcache_lzo_init " Lars-Peter Clausen
2011-11-15 19:23 ` [PATCH 1/2] regmap: Do not call regcache_exit from regcache_rbtree_init " Mark Brown
2011-11-14 15:44 ` [PATCH 1/5] regmap: return ERR_PTR instead of NULL in regmap_init Dimitris Papastamos
2011-11-14 21:44 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1321263619-25891-2-git-send-email-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=dp@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®