From: Colin King <colin.king@canonical.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
linux-kernel@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org
Subject: [PATCH] clocksource/drivers/davinci: fix memory leak on clockevent on error return
Date: Sat, 9 Nov 2019 15:58:36 +0000 [thread overview]
Message-ID: <20191109155836.223635-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
In the case where request_irq fails, the return path does not kfree
clockevent and hence we have a memory leak. Fix this by kfree'ing
clockevent before returning.
Addresses-Coverity: ("Resource leak")
Fixes: 721154f972aa ("clocksource/drivers/davinci: Add support for clockevents")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/clocksource/timer-davinci.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/clocksource/timer-davinci.c b/drivers/clocksource/timer-davinci.c
index 62745c962049..910d4d2f0d64 100644
--- a/drivers/clocksource/timer-davinci.c
+++ b/drivers/clocksource/timer-davinci.c
@@ -299,6 +299,7 @@ int __init davinci_timer_register(struct clk *clk,
"clockevent/tim12", clockevent);
if (rv) {
pr_err("Unable to request the clockevent interrupt");
+ kfree(clockevent);
return rv;
}
--
2.20.1
next reply other threads:[~2019-11-09 15:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-09 15:58 Colin King [this message]
2019-11-10 15:59 ` [PATCH] clocksource/drivers/davinci: fix memory leak on clockevent on error return Bartosz Golaszewski
2019-11-11 23:37 ` Thomas Gleixner
2019-11-12 8:34 ` Bartosz Golaszewski
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=20191109155836.223635-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=bgolaszewski@baylibre.com \
--cc=daniel.lezcano@linaro.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).