Skip to contentSkip to conversation

net/mlx5: Use kfree(ft->g) in arfs_create_groups()

PATCH In review Denis Efremov 3 participants 3 messages Jun 5, 2020 – Jun 11, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: Use kfree(ft->g) in arfs_create_groups()

Use kfree() instead of kvfree() on ft->g in arfs_create_groups() because the memory is allocated with kcalloc().

---
 drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c +1 -1
index 014639ea06e3..c4c9d6cda7e6 100644
@@ -220,7 +220,7 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
 			sizeof(*ft->g), GFP_KERNEL);
 	in = kvzalloc(inlen, GFP_KERNEL);
 	if  (!in || !ft->g) {
-		kvfree(ft->g);
+		kfree(ft->g);
 		kvfree(in);
 		return -ENOMEM;
 	}
Signature · 1 line
2.26.2
#1 lore raw
Quoted 14 lines · Denis Efremov

Use kfree() instead of kvfree() on ft->g in arfs_create_groups() because the memory is allocated with kcalloc().

---
 drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c +0 -0
index 014639ea06e3..c4c9d6cda7e6 100644

drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c static int arfs_create_groups(struct mlx5e_flow_table *ft, · line 226

Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c +1 -1
@@ -220,7 +220,7 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
 			sizeof(*ft->g), GFP_KERNEL);
 	in = kvzalloc(inlen, GFP_KERNEL);
 	if  (!in || !ft->g) {
-		kvfree(ft->g);
+		kfree(ft->g);
 		kvfree(in);
 		return -ENOMEM;
 	}

This is slow path, kvfree() is perfectly able to free memory that was kmalloc()ed

net-next is closed, can we avoid these patches during merge window ?

#2 lore raw
Quoted 31 lines · Eric Dumazet
Quoted 23 lines · Denis Efremov

Use kfree() instead of kvfree() on ft->g in arfs_create_groups() because
the memory is allocated with kcalloc().

---
 drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c +1 -1
index 014639ea06e3..c4c9d6cda7e6 100644
@@ -220,7 +220,7 @@ static int arfs_create_groups(struct
 mlx5e_flow_table *ft,
 			sizeof(*ft->g), GFP_KERNEL);
 	in = kvzalloc(inlen, GFP_KERNEL);
 	if  (!in || !ft->g) {
-		kvfree(ft->g);
+		kfree(ft->g);
 		kvfree(in);
 		return -ENOMEM;
Quoted 2 lines

}

This is slow path, kvfree() is perfectly able to free memory that was kmalloc()ed

Quoted 1 line

net-next is closed, can we avoid these patches during merge window ?

I agree, with Eric, better if we wait for net-next to open.

I will apply this once net-next is open.

Thanks,
Saeed.