mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mfd mc13xxxx: Set mc_dev to NULL on failure
@ 2012-05-16 10:58 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2012-05-16 10:58 UTC (permalink / raw)
  To: barebox

The mc13xxx driver correctly bails out on failure, but leaves
mc_dev initialized, so a later mc13xxx_get won't fail but returns
an invalid pointer. Fix this. While at it, remove some superfluous
code from mc13xxx_get.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mfd/mc13xxx.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mfd/mc13xxx.c b/drivers/mfd/mc13xxx.c
index ad7cb7e..f9477a3 100644
--- a/drivers/mfd/mc13xxx.c
+++ b/drivers/mfd/mc13xxx.c
@@ -38,9 +38,6 @@ static struct mc13xxx *mc_dev;
 
 struct mc13xxx *mc13xxx_get(void)
 {
-	if (!mc_dev)
-		return NULL;
-
 	return mc_dev;
 }
 EXPORT_SYMBOL(mc13xxx_get);
@@ -308,6 +305,7 @@ static int mc_probe(struct device_d *dev, enum mc13xxx_mode mode)
 	rev = mc13xxx_query_revision(mc_dev);
 	if (rev < 0) {
 		free(mc_dev);
+		mc_dev = NULL;
 		return -EINVAL;
 	}
 
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-05-16 10:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-16 10:58 [PATCH] mfd mc13xxxx: Set mc_dev to NULL on failure Sascha Hauer

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