diff options
author | Colin Ian King <colin.king@canonical.com> | 2017-11-22 18:16:18 +0100 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2017-12-18 23:05:10 +0100 |
commit | e9982024619c7f8f8cce97b0038a0075b135089c (patch) | |
tree | c3a6510272d19ac97b44b316d6be4ae775de6c4d /drivers/rtc | |
parent | rtc: cros-ec: add cros-ec-rtc driver. (diff) | |
download | linux-e9982024619c7f8f8cce97b0038a0075b135089c.tar.xz linux-e9982024619c7f8f8cce97b0038a0075b135089c.zip |
rtc: sun6i: ensure rtc is kfree'd on error
The error return path on clk_data allocation failure does not kfree
the allocated rtc object. Fix this with a kfree of rtc on the error
exit path.
Detected by CoverityScan, CID#1452264 ("Resource Leak")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-sun6i.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c index 3d2216ccd860..5bc28eed1adf 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c @@ -201,8 +201,10 @@ static void __init sun6i_rtc_clk_init(struct device_node *node) clk_data = kzalloc(sizeof(*clk_data) + (sizeof(*clk_data->hws) * 2), GFP_KERNEL); - if (!clk_data) + if (!clk_data) { + kfree(rtc); return; + } spin_lock_init(&rtc->lock); |