From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org,
Colin Ian King <colin.king@canonical.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>,
bcm-kernel-feedback-list@broadcom.com (maintainer:BROADCOM
BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...),
Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM
BCM2711/BCM2835 ARM ARCHITECTURE),
linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM
BCM2711/BCM2835 ARM ARCHITECTURE)
Subject: [PATCH 08/17] clocksource/drivers/bcm2835_timer: Fix memory leak of timer
Date: Thu, 16 Jan 2020 19:22:55 +0100 [thread overview]
Message-ID: <20200116182304.4926-8-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <20200116182304.4926-1-daniel.lezcano@linaro.org>
From: Colin Ian King <colin.king@canonical.com>
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 2b196cbfadb6..b235f446ee50 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;
--
2.17.1
next prev parent reply other threads:[~2020-01-16 18:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-16 18:21 [GIT PULL] timer drivers for 5.6 Daniel Lezcano
2020-01-16 18:22 ` [PATCH 01/17] clocksource/drivers/hyper-v: Suspend/resume Hyper-V clocksource for hibernation Daniel Lezcano
2020-01-16 18:22 ` [PATCH 02/17] clocksource: Fix Kconfig indentation Daniel Lezcano
2020-01-16 18:22 ` [PATCH 03/17] dt-bindings: timer: renesas, cmt: Document r8a774b1 CMT support Daniel Lezcano
2020-01-16 18:22 ` [PATCH 04/17] clocksource: Fix Kconfig miscues Daniel Lezcano
2020-01-16 18:22 ` [PATCH 05/17] clocksource/drivers/hyper-v: Reserve PAGE_SIZE space for tsc page Daniel Lezcano
2020-01-16 18:22 ` [PATCH 06/17] clocksource/drivers/timer-microchip-pit64b: Add Microchip PIT64B support Daniel Lezcano
2020-01-16 18:22 ` [PATCH 07/17] clocksource/drivers/cadence-ttc: Use ttc driver as platform driver Daniel Lezcano
2020-01-16 18:22 ` Daniel Lezcano [this message]
2020-01-16 18:22 ` [PATCH 09/17] clocksource/drivers/em_sti: Convert to devm_platform_ioremap_resource Daniel Lezcano
2020-01-16 18:22 ` [PATCH 10/17] clocksource/drivers/em_sti: Fix variable declaration in em_sti_probe Daniel Lezcano
2020-01-16 18:22 ` [PATCH 11/17] clocksource/drivers/timer-ti-dm: Convert to devm_platform_ioremap_resource Daniel Lezcano
2020-01-16 18:22 ` [PATCH 12/17] clocksource/drivers/timer-ti-dm: Switch to platform_get_irq Daniel Lezcano
2020-01-16 18:23 ` [PATCH 13/17] clocksource/drivers/timer-ti-dm: Fix uninitialized pointer access Daniel Lezcano
2020-01-16 18:23 ` [PATCH 14/17] clocksource/drivers/exynos_mct: Rename Exynos to lowercase Daniel Lezcano
2020-01-16 18:23 ` [PATCH 15/17] clocksource/drivers/timer-microchip-pit64b: Fix sparse warning Daniel Lezcano
2020-01-16 18:23 ` [PATCH 16/17] clocksource/drivers/hyper-v: Untangle stimers and timesync from clocksources Daniel Lezcano
2020-01-16 18:23 ` [PATCH 17/17] clocksource/drivers/hyper-v: Set TSC clocksource as default w/ InvariantTSC Daniel Lezcano
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=20200116182304.4926-8-daniel.lezcano@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=colin.king@canonical.com \
--cc=f.fainelli@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=nsaenzjulienne@suse.de \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
--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
all inboxes | Powered by JetHome®