public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] regmap: return ERR_PTR instead of NULL in regmap_init
@ 2011-11-14  9:40 Lars-Peter Clausen
  2011-11-14  9:40 ` [PATCH 2/5] regmap: Fix memory leak in regcache_hw_init error path Lars-Peter Clausen
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Lars-Peter Clausen @ 2011-11-14  9:40 UTC (permalink / raw)
  To: Mark Brown; +Cc: Dimitris Papastamos, linux-kernel, Lars-Peter Clausen

The regmap_init documentation states that it will either return a pointer to a
valid regmap structure or a ERR_PTR in case of an error. Currently it returns a
NULL pointer in case no bus or no config was given. Since NULL is not a
ERR_PTR a caller might assume that it is a pointer to a valid regmap structure,
so return a ERR_PTR(-EINVAL) instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/base/regmap/regmap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index b08df85..b84ebf9 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -139,7 +139,7 @@ struct regmap *regmap_init(struct device *dev,
 	int ret = -EINVAL;
 
 	if (!bus || !config)
-		return NULL;
+		goto err;
 
 	map = kzalloc(sizeof(*map), GFP_KERNEL);
 	if (map == NULL) {
-- 
1.7.7.1



^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-11-15 19:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/5] regmap: Fix memory leak in regcache_hw_init error path Lars-Peter Clausen
2011-11-14 21:45   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox