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

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 <xkernel.wang@foxmail.com>
Link: https://lore.kernel.org/r/tencent_2B9817738F38B02844C245946EFF3B407E09@qq.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Xiaoke Wang and committed by
Stephen Boyd
117a1542 e11a47f5

+2
+2
drivers/clk/pxa/clk-pxa.c
··· 104 104 105 105 for (i = 0; i < nb_clks; i++) { 106 106 pxa_clk = kzalloc(sizeof(*pxa_clk), GFP_KERNEL); 107 + if (!pxa_clk) 108 + return -ENOMEM; 107 109 pxa_clk->is_in_low_power = clks[i].is_in_low_power; 108 110 pxa_clk->lp = clks[i].lp; 109 111 pxa_clk->hp = clks[i].hp;