lkml.org 
[lkml]   [2022]   [Apr]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] clk: pxa: add a check for the return value of kzalloc()
From
Date
Quoting xkernel.wang@foxmail.com (2022-03-25 03:27:20)
> From: Xiaoke Wang <xkernel.wang@foxmail.com>
>
> 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>
> ---
> drivers/clk/pxa/clk-pxa.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/clk/pxa/clk-pxa.c b/drivers/clk/pxa/clk-pxa.c
> index cfc79f9..d0df104 100644
> --- a/drivers/clk/pxa/clk-pxa.c
> +++ b/drivers/clk/pxa/clk-pxa.c
> @@ -102,6 +102,8 @@ int __init clk_pxa_cken_init(const struct desc_clk_cken *clks, int nb_clks)
>
> for (i = 0; i < nb_clks; i++) {
> pxa_clk = kzalloc(sizeof(*pxa_clk), GFP_KERNEL);
> + if (!pxa_clk)
> + continue;

Shouldn't we stop trying to allocate more and return an error?

\
 
 \ /
  Last update: 2022-04-07 17:29    [W:0.026 / U:0.392 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site