Skip to content

Commit 117a154

Browse files
x2018bebarino
authored andcommitted
clk: pxa: add a check for the return value of kzalloc()
kzalloc() is a memory allocation function which can return NULL when some internal memory errors happen. So it is better to check it to prevent potential wrong memory access. Signed-off-by: Xiaoke Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent e11a47f commit 117a154

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/clk/pxa/clk-pxa.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ int __init clk_pxa_cken_init(const struct desc_clk_cken *clks,
104104

105105
for (i = 0; i < nb_clks; i++) {
106106
pxa_clk = kzalloc(sizeof(*pxa_clk), GFP_KERNEL);
107+
if (!pxa_clk)
108+
return -ENOMEM;
107109
pxa_clk->is_in_low_power = clks[i].is_in_low_power;
108110
pxa_clk->lp = clks[i].lp;
109111
pxa_clk->hp = clks[i].hp;

0 commit comments

Comments
 (0)