Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 26b3b6b959b2 ("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>

authored by

Liang He and committed by
Stephen Boyd
37c381b8 b3ff02c5

+9 -2
+4 -1
drivers/clk/berlin/bg2.c
··· 500 500 int n, ret; 501 501 502 502 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); 504 505 return; 506 + } 505 507 clk_data->num = MAX_CLKS; 506 508 hws = clk_data->hws; 507 509 508 510 gbase = of_iomap(parent_np, 0); 511 + of_node_put(parent_np); 509 512 if (!gbase) 510 513 return; 511 514
+5 -1
drivers/clk/berlin/bg2q.c
··· 286 286 int n, ret; 287 287 288 288 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); 290 291 return; 292 + } 291 293 clk_data->num = MAX_CLKS; 292 294 hws = clk_data->hws; 293 295 294 296 gbase = of_iomap(parent_np, 0); 295 297 if (!gbase) { 298 + of_node_put(parent_np); 296 299 pr_err("%pOF: Unable to map global base\n", np); 297 300 return; 298 301 } 299 302 300 303 /* BG2Q CPU PLL is not part of global registers */ 301 304 cpupll_base = of_iomap(parent_np, 1); 305 + of_node_put(parent_np); 302 306 if (!cpupll_base) { 303 307 pr_err("%pOF: Unable to map cpupll base\n", np); 304 308 iounmap(gbase);