summaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2016-01-06 22:17:31 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2016-01-07 08:46:09 +0100
commit304cdde1677a77af010241801454dd58f2675fbe (patch)
treed8c6a8865fbfc4590fc3cc5b810f34dad005288d /drivers/rtc
parent540140849c1f4b3274854e6e26a1fdfb6c728a8f (diff)
downloadbarebox-304cdde1677a77af010241801454dd58f2675fbe.tar.gz
barebox-304cdde1677a77af010241801454dd58f2675fbe.tar.xz
rtc: ds1307: Fix a memory leak
Several failure paths would result in control being transfered to 'exit' label, so instead of just returning error codes in those cases we also need to free the memory allocated for 'ds1307' Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-ds1307.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 2b46ae54f6..e2d561b96f 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -17,6 +17,7 @@
#include <init.h>
#include <driver.h>
#include <xfuncs.h>
+#include <malloc.h>
#include <errno.h>
#include <i2c/i2c.h>
#include <rtc.h>
@@ -422,6 +423,8 @@ read_rtc:
err = rtc_register(&ds1307->rtc);
exit:
+ if (err)
+ free(ds1307);
return err;
}