Skip to content

Commit

Permalink
rtc: sun6i: ensure rtc is kfree'd on error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Colin Ian King authored and alexandrebelloni committed Dec 18, 2017
1 parent 6f2a71a commit e998202
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/rtc/rtc-sun6i.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit e998202

Please sign in to comment.