Skip to contentSkip to conversation

net/mlx5: use kvfree() for memory allocated with kvzalloc()

PATCH Applied angkery 3 participants 3 messages Mar 3, 2021 – Mar 11, 2021

Subsystems (4)
lore
Share & tools
lore

angkery

author
#0 lore raw

PATCH 1/1 net/mlx5: use kvfree() for memory allocated with kvzalloc()

From: Junlin Yang <[email protected]>

It is allocated with kvzalloc(), the corresponding release function should not be kfree(), use kvfree() instead.

Generated by: scripts/coccinelle/api/kfree_mismatch.cocci

---
 drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c +5 -5
index 6f6772b..3da7bec 100644
@@ -248,7 +248,7 @@ static int mlx5_esw_indir_table_rule_get(struct mlx5_eswitch *esw,
 err_ethertype:
 	kfree(rule);
 out:
-	kfree(rule_spec);
+	kvfree(rule_spec);
 	return err;
 }
 
@@ -328,7 +328,7 @@ static int mlx5_create_indir_recirc_group(struct mlx5_eswitch *esw,
 	e->recirc_cnt = 0;
 
 out:
-	kfree(in);
+	kvfree(in);
 	return err;
 }
 
@@ -347,7 +347,7 @@ static int mlx5_create_indir_fwd_group(struct mlx5_eswitch *esw,
 
 	spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
 	if (!spec) {
-		kfree(in);
+		kvfree(in);
 		return -ENOMEM;
 	}
 
@@ -371,8 +371,8 @@ static int mlx5_create_indir_fwd_group(struct mlx5_eswitch *esw,
 	}
 
 err_out:
-	kfree(spec);
-	kfree(in);
+	kvfree(spec);
+	kvfree(in);
 	return err;
 }
 
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 45 lines · angkery

From: Junlin Yang <[email protected]>

It is allocated with kvzalloc(), the corresponding release function should not be kfree(), use kvfree() instead.

Generated by: scripts/coccinelle/api/kfree_mismatch.cocci

---
  drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c +3 -3
index 6f6772b..3da7bec 100644
@@ -248,7 +248,7 @@ static int mlx5_esw_indir_table_rule_get(struct mlx5_eswitch *esw,
  err_ethertype:
  	kfree(rule);
  out:
-	kfree(rule_spec);
+	kvfree(rule_spec);
  	return err;
  }
 
@@ -328,7 +328,7 @@ static int mlx5_create_indir_recirc_group(struct mlx5_eswitch *esw,
  	e->recirc_cnt = 0;
 
  out:
-	kfree(in);
+	kvfree(in);
  	return err;
  }
 
@@ -347,7 +347,7 @@ static int mlx5_create_indir_fwd_group(struct mlx5_eswitch *esw,
 
  	spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
  	if (!spec) {
-		kfree(in);
+		kvfree(in);
  		return -ENOMEM;
  	}
 

drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c static int mlx5_create_indir_fwd_group(struct mlx5_eswitch *esw, · line 378

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c +2 -2
@@ -371,8 +371,8 @@ static int mlx5_create_indir_fwd_group(struct mlx5_eswitch *esw,
  	}
 
  err_out:
-	kfree(spec);
-	kfree(in);
+	kvfree(spec);
+	kvfree(in);
  	return err;
  }
 

thanks!

#2 lore raw
Quoted 68 lines · Roi Dayan
Quoted 53 lines · angkery

From: Junlin Yang <[email protected]>

It is allocated with kvzalloc(), the corresponding release function should not be kfree(), use kvfree() instead.

Generated by: scripts/coccinelle/api/kfree_mismatch.cocci

---
  drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c | 10
+++++-----

  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c index 6f6772b..3da7bec 100644

drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c +0 -0
@@ -248,7 +248,7 @@ static int mlx5_esw_indir_table_rule_get(struct
 mlx5_eswitch *esw,

  err_ethertype:
        kfree(rule);
  out:
-       kfree(rule_spec);
+       kvfree(rule_spec);
        return err;
  }

drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c +0 -0
@@ -328,7 +328,7 @@ static int
 mlx5_create_indir_recirc_group(struct mlx5_eswitch *esw,
         e->recirc_cnt = 0;


  out:
-       kfree(in);
+       kvfree(in);
        return err;
  }

drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c +0 -0
@@ -347,7 +347,7 @@ static int mlx5_create_indir_fwd_group(struct
 mlx5_eswitch *esw,


        spec = kvzalloc(sizeof(*spec), GFP_KERNEL); if (!spec) {
-               kfree(in);
+               kvfree(in);
                return -ENOMEM;
        }

drivers/net/ethernet/mellanox/mlx5/core/esw/indir_table.c +0 -0
@@ -371,8 +371,8 @@ static int mlx5_create_indir_fwd_group(struct
 mlx5_eswitch *esw,
         }

Quoted 9 lines

  err_out:
-       kfree(spec);
-       kfree(in);
+       kvfree(spec);
+       kvfree(in);
        return err;
  }

thanks!

Quoted 2 lines

applied to net-next-mlx5