clk: berlin: Add of_node_put() for of_get_parent()
[ Upstream commit37c381b812] 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:26b3b6b959("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
dc190b46c6
commit
57141b1dd6
@@ -500,12 +500,15 @@ static void __init berlin2_clock_setup(struct device_node *np)
|
|||||||
int n, ret;
|
int n, ret;
|
||||||
|
|
||||||
clk_data = kzalloc(struct_size(clk_data, hws, MAX_CLKS), GFP_KERNEL);
|
clk_data = kzalloc(struct_size(clk_data, hws, MAX_CLKS), GFP_KERNEL);
|
||||||
if (!clk_data)
|
if (!clk_data) {
|
||||||
|
of_node_put(parent_np);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
clk_data->num = MAX_CLKS;
|
clk_data->num = MAX_CLKS;
|
||||||
hws = clk_data->hws;
|
hws = clk_data->hws;
|
||||||
|
|
||||||
gbase = of_iomap(parent_np, 0);
|
gbase = of_iomap(parent_np, 0);
|
||||||
|
of_node_put(parent_np);
|
||||||
if (!gbase)
|
if (!gbase)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -286,19 +286,23 @@ static void __init berlin2q_clock_setup(struct device_node *np)
|
|||||||
int n, ret;
|
int n, ret;
|
||||||
|
|
||||||
clk_data = kzalloc(struct_size(clk_data, hws, MAX_CLKS), GFP_KERNEL);
|
clk_data = kzalloc(struct_size(clk_data, hws, MAX_CLKS), GFP_KERNEL);
|
||||||
if (!clk_data)
|
if (!clk_data) {
|
||||||
|
of_node_put(parent_np);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
clk_data->num = MAX_CLKS;
|
clk_data->num = MAX_CLKS;
|
||||||
hws = clk_data->hws;
|
hws = clk_data->hws;
|
||||||
|
|
||||||
gbase = of_iomap(parent_np, 0);
|
gbase = of_iomap(parent_np, 0);
|
||||||
if (!gbase) {
|
if (!gbase) {
|
||||||
|
of_node_put(parent_np);
|
||||||
pr_err("%pOF: Unable to map global base\n", np);
|
pr_err("%pOF: Unable to map global base\n", np);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* BG2Q CPU PLL is not part of global registers */
|
/* BG2Q CPU PLL is not part of global registers */
|
||||||
cpupll_base = of_iomap(parent_np, 1);
|
cpupll_base = of_iomap(parent_np, 1);
|
||||||
|
of_node_put(parent_np);
|
||||||
if (!cpupll_base) {
|
if (!cpupll_base) {
|
||||||
pr_err("%pOF: Unable to map cpupll base\n", np);
|
pr_err("%pOF: Unable to map cpupll base\n", np);
|
||||||
iounmap(gbase);
|
iounmap(gbase);
|
||||||
|
|||||||
Reference in New Issue
Block a user