Skip to content

Commit 37c381b

Browse files
windhlbebarino
authored andcommitted
clk: berlin: Add of_node_put() for of_get_parent()
In berlin2_clock_setup() and berlin2q_clock_setup(), we need to call of_node_put() for the reference returned by of_get_parent() which has increased the refcount. We should call *_put() in fail path or when it is not used anymore. Fixes: 26b3b6b ("clk: berlin: prepare simple-mfd conversion") Signed-off-by: Liang He <windhl@126.com> Link: https://lore.kernel.org/r/20220708084900.311684-1-windhl@126.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent b3ff02c commit 37c381b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

drivers/clk/berlin/bg2.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,15 @@ static void __init berlin2_clock_setup(struct device_node *np)
500500
int n, ret;
501501

502502
clk_data = kzalloc(struct_size(clk_data, hws, MAX_CLKS), GFP_KERNEL);
503-
if (!clk_data)
503+
if (!clk_data) {
504+
of_node_put(parent_np);
504505
return;
506+
}
505507
clk_data->num = MAX_CLKS;
506508
hws = clk_data->hws;
507509

508510
gbase = of_iomap(parent_np, 0);
511+
of_node_put(parent_np);
509512
if (!gbase)
510513
return;
511514

drivers/clk/berlin/bg2q.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,19 +286,23 @@ static void __init berlin2q_clock_setup(struct device_node *np)
286286
int n, ret;
287287

288288
clk_data = kzalloc(struct_size(clk_data, hws, MAX_CLKS), GFP_KERNEL);
289-
if (!clk_data)
289+
if (!clk_data) {
290+
of_node_put(parent_np);
290291
return;
292+
}
291293
clk_data->num = MAX_CLKS;
292294
hws = clk_data->hws;
293295

294296
gbase = of_iomap(parent_np, 0);
295297
if (!gbase) {
298+
of_node_put(parent_np);
296299
pr_err("%pOF: Unable to map global base\n", np);
297300
return;
298301
}
299302

300303
/* BG2Q CPU PLL is not part of global registers */
301304
cpupll_base = of_iomap(parent_np, 1);
305+
of_node_put(parent_np);
302306
if (!cpupll_base) {
303307
pr_err("%pOF: Unable to map cpupll base\n", np);
304308
iounmap(gbase);

0 commit comments

Comments
 (0)