Message ID | 20220312102705.71413-3-Julia.Lawall@inria.fr (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | use kzalloc | expand |
On 3/12/2022 12:27 PM, Julia Lawall wrote: > Use kzalloc instead of kmalloc + memset. > > The semantic patch that makes this change is: > (https://coccinelle.gitlabpages.inria.fr/website/) > > //<smpl> > @@ > expression res, size, flag; > @@ > - res = kmalloc(size, flag); > + res = kzalloc(size, flag); > ... > - memset(res, 0, size); > //</smpl> > > Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> > > --- > drivers/net/ethernet/mellanox/mlx4/en_rx.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c > index 8cfc649f226b..8f762fc170b3 100644 > --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c > +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c > @@ -1067,7 +1067,7 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn, > struct mlx4_qp_context *context; > int err = 0; > > - context = kmalloc(sizeof(*context), GFP_KERNEL); > + context = kzalloc(sizeof(*context), GFP_KERNEL); > if (!context) > return -ENOMEM; > > @@ -1078,7 +1078,6 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn, > } > qp->event = mlx4_en_sqp_event; > > - memset(context, 0, sizeof(*context)); > mlx4_en_fill_qp_context(priv, ring->actual_size, ring->stride, 0, 0, > qpn, ring->cqn, -1, context); > context->db_rec_addr = cpu_to_be64(ring->wqres.db.dma); > Thanks for your patch. Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index 8cfc649f226b..8f762fc170b3 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -1067,7 +1067,7 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn, struct mlx4_qp_context *context; int err = 0; - context = kmalloc(sizeof(*context), GFP_KERNEL); + context = kzalloc(sizeof(*context), GFP_KERNEL); if (!context) return -ENOMEM; @@ -1078,7 +1078,6 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn, } qp->event = mlx4_en_sqp_event; - memset(context, 0, sizeof(*context)); mlx4_en_fill_qp_context(priv, ring->actual_size, ring->stride, 0, 0, qpn, ring->cqn, -1, context); context->db_rec_addr = cpu_to_be64(ring->wqres.db.dma);
Use kzalloc instead of kmalloc + memset. The semantic patch that makes this change is: (https://coccinelle.gitlabpages.inria.fr/website/) //<smpl> @@ expression res, size, flag; @@ - res = kmalloc(size, flag); + res = kzalloc(size, flag); ... - memset(res, 0, size); //</smpl> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> --- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)