Skip to content

Commit e998202

Browse files
Colin Ian Kingalexandrebelloni
Colin Ian King
authored andcommitted
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 6f2a71a commit e998202

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/rtc/rtc-sun6i.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,10 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
201201

202202
clk_data = kzalloc(sizeof(*clk_data) + (sizeof(*clk_data->hws) * 2),
203203
GFP_KERNEL);
204-
if (!clk_data)
204+
if (!clk_data) {
205+
kfree(rtc);
205206
return;
207+
}
206208

207209
spin_lock_init(&rtc->lock);
208210

0 commit comments

Comments
 (0)