From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aH3uu-00076P-Ns for barebox@lists.infradead.org; Thu, 07 Jan 2016 06:19:25 +0000 Received: by mail-pa0-x22a.google.com with SMTP id qh10so93357pab.2 for ; Wed, 06 Jan 2016 22:19:04 -0800 (PST) From: Andrey Smirnov Date: Wed, 6 Jan 2016 22:17:31 -0800 Message-Id: <1452147455-26524-2-git-send-email-andrew.smirnov@gmail.com> In-Reply-To: <1452147455-26524-1-git-send-email-andrew.smirnov@gmail.com> References: <1452147455-26524-1-git-send-email-andrew.smirnov@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 2/6] rtc: ds1307: Fix a memory leak To: barebox@lists.infradead.org Cc: Andrey Smirnov 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 --- drivers/rtc/rtc-ds1307.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 2b46ae5..e2d561b 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -422,6 +423,8 @@ read_rtc: err = rtc_register(&ds1307->rtc); exit: + if (err) + free(ds1307); return err; } -- 2.5.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox