2020-12-30 08:22:53

by Zheng Yongjun

[permalink] [raw]
Subject: [PATCH net-next] net/mlxfw: Use kzalloc for allocating only one thing

Use kzalloc rather than kcalloc(1,...)

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
@@

- kcalloc(1,
+ kzalloc(
...)
// </smpl>

Signed-off-by: Zheng Yongjun <[email protected]>
---
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
index 5d9ddf36fb4e..e6f677e42007 100644
--- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
+++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
@@ -267,7 +267,7 @@ struct mlxfw_mfa2_file *mlxfw_mfa2_file_init(const struct firmware *fw)
const void *first_tlv_ptr;
const void *cb_top_ptr;

- mfa2_file = kcalloc(1, sizeof(*mfa2_file), GFP_KERNEL);
+ mfa2_file = kzalloc(sizeof(*mfa2_file), GFP_KERNEL);
if (!mfa2_file)
return ERR_PTR(-ENOMEM);

--
2.22.0


2020-12-30 10:51:45

by Ido Schimmel

[permalink] [raw]
Subject: Re: [PATCH net-next] net/mlxfw: Use kzalloc for allocating only one thing

On Wed, Dec 30, 2020 at 04:18:35PM +0800, Zheng Yongjun wrote:
> Use kzalloc rather than kcalloc(1,...)
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> @@
>
> - kcalloc(1,
> + kzalloc(
> ...)
> // </smpl>
>
> Signed-off-by: Zheng Yongjun <[email protected]>

Reviewed-by: Ido Schimmel <[email protected]>

Thanks

2021-01-06 00:49:00

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net-next] net/mlxfw: Use kzalloc for allocating only one thing

From: Zheng Yongjun <[email protected]>
Date: Wed, 30 Dec 2020 16:18:35 +0800

> Use kzalloc rather than kcalloc(1,...)
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> @@
>
> - kcalloc(1,
> + kzalloc(
> ...)
> // </smpl>
>
> Signed-off-by: Zheng Yongjun <[email protected]>

Applied.