lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1d24bd65-e278-5562-a097-39a68470a1d4@wanadoo.fr>
Date:   Tue, 1 Mar 2022 19:10:19 +0100
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Dan Carpenter <dan.carpenter@...cle.com>,
        Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Cc:     Rafał Miłecki <rafal@...ecki.pl>,
        linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] nvmem: check for allocation failure

Le 01/03/2022 à 09:11, Dan Carpenter a écrit :
> Check for if the kcalloc() fails.
> 
> Fixes: 299dc152721f ("nvmem: brcm_nvram: parse NVRAM content into NVMEM cells")
> Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
> ---
>   drivers/nvmem/brcm_nvram.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/nvmem/brcm_nvram.c b/drivers/nvmem/brcm_nvram.c
> index 439f00b9eef6..c80af8a31eba 100644
> --- a/drivers/nvmem/brcm_nvram.c
> +++ b/drivers/nvmem/brcm_nvram.c
> @@ -95,6 +95,8 @@ static int brcm_nvram_parse(struct brcm_nvram *priv)
>   	len = le32_to_cpu(header.len);
>   
>   	data = kcalloc(1, len, GFP_KERNEL);

Hi,

just for my understanding, why
   - kcalloc(1, len) and not kzalloc(len)?
   - kcalloc and not kmalloc_array, since data is fully filled just the 
line below by memcpy_fromio()?

CJ

> +	if (!data)
> +		return -ENOMEM;
>   	memcpy_fromio(data, priv->base, len);
>   	data[len - 1] = '\0';
>   

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ