2022-08-10 03:49:32

by Kenneth Lee

[permalink] [raw]
Subject: [PATCH] nvmem: brcm_nvram: Use kzalloc for allocating only one element

Use kzalloc(...) rather than kcalloc(1, ...) because the number of
elements we are specifying in this case is 1, so kzalloc would
accomplish the same thing and we can simplify.

Signed-off-by: Kenneth Lee <[email protected]>
---
drivers/nvmem/brcm_nvram.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/brcm_nvram.c b/drivers/nvmem/brcm_nvram.c
index 450b927691c3..4441daa20965 100644
--- a/drivers/nvmem/brcm_nvram.c
+++ b/drivers/nvmem/brcm_nvram.c
@@ -96,7 +96,7 @@ static int brcm_nvram_parse(struct brcm_nvram *priv)

len = le32_to_cpu(header.len);

- data = kcalloc(1, len, GFP_KERNEL);
+ data = kzalloc(len, GFP_KERNEL);
memcpy_fromio(data, priv->base, len);
data[len - 1] = '\0';

--
2.31.1


2022-08-17 12:33:56

by Srinivas Kandagatla

[permalink] [raw]
Subject: Re: [PATCH] nvmem: brcm_nvram: Use kzalloc for allocating only one element



On 10/08/2022 04:10, Kenneth Lee wrote:
> Use kzalloc(...) rather than kcalloc(1, ...) because the number of
> elements we are specifying in this case is 1, so kzalloc would
> accomplish the same thing and we can simplify.
>
> Signed-off-by: Kenneth Lee <[email protected]>
> ---

Applied thanks,

--srini
> drivers/nvmem/brcm_nvram.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvmem/brcm_nvram.c b/drivers/nvmem/brcm_nvram.c
> index 450b927691c3..4441daa20965 100644
> --- a/drivers/nvmem/brcm_nvram.c
> +++ b/drivers/nvmem/brcm_nvram.c
> @@ -96,7 +96,7 @@ static int brcm_nvram_parse(struct brcm_nvram *priv)
>
> len = le32_to_cpu(header.len);
>
> - data = kcalloc(1, len, GFP_KERNEL);
> + data = kzalloc(len, GFP_KERNEL);
> memcpy_fromio(data, priv->base, len);
> data[len - 1] = '\0';
>