All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Colin Ian King" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Colin Ian King <colin.king@canonical.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>, x86 <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [tip: timers/core] clocksource/drivers/bcm2835_timer: Fix memory leak of timer
Date: Thu, 16 Jan 2020 21:31:01 -0000	[thread overview]
Message-ID: <157921026162.396.6792209915376848166.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20191219213246.34437-1-colin.king@canonical.com>

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     2052d032c06761330bca4944bb7858b00960e868
Gitweb:        https://git.kernel.org/tip/2052d032c06761330bca4944bb7858b00960e868
Author:        Colin Ian King <colin.king@canonical.com>
AuthorDate:    Thu, 19 Dec 2019 21:32:46 
Committer:     Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Thu, 16 Jan 2020 19:06:57 +01:00

clocksource/drivers/bcm2835_timer: Fix memory leak of timer

Currently when setup_irq fails the error exit path will leak the
recently allocated timer structure.  Originally the code would
throw a panic but a later commit changed the behaviour to return
via the err_iounmap path and hence we now have a memory leak. Fix
this by adding a err_timer_free error path that kfree's timer.

Addresses-Coverity: ("Resource Leak")
Fixes: 524a7f08983d ("clocksource/drivers/bcm2835_timer: Convert init function to return error")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20191219213246.34437-1-colin.king@canonical.com
---
 drivers/clocksource/bcm2835_timer.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/bcm2835_timer.c b/drivers/clocksource/bcm2835_timer.c
index 2b196cb..b235f44 100644
--- a/drivers/clocksource/bcm2835_timer.c
+++ b/drivers/clocksource/bcm2835_timer.c
@@ -121,7 +121,7 @@ static int __init bcm2835_timer_init(struct device_node *node)
 	ret = setup_irq(irq, &timer->act);
 	if (ret) {
 		pr_err("Can't set up timer IRQ\n");
-		goto err_iounmap;
+		goto err_timer_free;
 	}
 
 	clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff);
@@ -130,6 +130,9 @@ static int __init bcm2835_timer_init(struct device_node *node)
 
 	return 0;
 
+err_timer_free:
+	kfree(timer);
+
 err_iounmap:
 	iounmap(base);
 	return ret;

      parent reply	other threads:[~2020-01-16 21:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-19 21:32 [PATCH] clocksource/drivers/bcm2835_timer: fix memory leak of timer Colin King
2019-12-19 21:32 ` Colin King
2019-12-20  9:58 ` Daniel Lezcano
2019-12-20  9:58   ` Daniel Lezcano
2019-12-20  9:58   ` Daniel Lezcano
2020-01-16 21:31 ` tip-bot2 for Colin Ian King [this message]

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=157921026162.396.6792209915376848166.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=colin.king@canonical.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.