[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201221085031.6591-1-dinghao.liu@zju.edu.cn>
Date: Mon, 21 Dec 2020 16:50:31 +0800
From: Dinghao Liu <dinghao.liu@....edu.cn>
To: dinghao.liu@....edu.cn, kjlu@....edu
Cc: Saeed Mahameed <saeedm@...dia.com>,
Leon Romanovsky <leon@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] net/mlx5e: Fix two double free cases
mlx5e_create_ttc_table_groups() frees ft->g on failure of
kvzalloc(), but such failure will be caught by its caller
in mlx5e_create_ttc_table() and ft->g will be freed again
in mlx5e_destroy_flow_table(). The same issue also occurs
in mlx5e_create_ttc_table_groups().
Signed-off-by: Dinghao Liu <dinghao.liu@....edu.cn>
---
drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
index fa8149f6eb08..63323c5b6a50 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
@@ -940,10 +940,8 @@ static int mlx5e_create_ttc_table_groups(struct mlx5e_ttc_table *ttc,
if (!ft->g)
return -ENOMEM;
in = kvzalloc(inlen, GFP_KERNEL);
- if (!in) {
- kfree(ft->g);
+ if (!in)
return -ENOMEM;
- }
/* L4 Group */
mc = MLX5_ADDR_OF(create_flow_group_in, in, match_criteria);
@@ -1085,10 +1083,8 @@ static int mlx5e_create_inner_ttc_table_groups(struct mlx5e_ttc_table *ttc)
if (!ft->g)
return -ENOMEM;
in = kvzalloc(inlen, GFP_KERNEL);
- if (!in) {
- kfree(ft->g);
+ if (!in)
return -ENOMEM;
- }
/* L4 Group */
mc = MLX5_ADDR_OF(create_flow_group_in, in, match_criteria);
--
2.17.1
Powered by blists - more mailing lists