Re: [PATCH] [v2] net/mlx5e: fix a potential double-free in fs_any_create_groups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 28/11/2023 11:29, Dinghao Liu wrote:
When kcalloc() for ft->g succeeds but kvzalloc() for in fails,
fs_any_create_groups() will free ft->g. However, its caller
fs_any_create_table() will free ft->g again through calling
mlx5e_destroy_flow_table(), which will lead to a double-free.
Fix this by setting ft->g to NULL in fs_any_create_groups().

Fixes: 0f575c20bf06 ("net/mlx5e: Introduce Flow Steering ANY API")
Signed-off-by: Dinghao Liu <dinghao.liu@xxxxxxxxxx>
---

Changelog:

v2: Setting ft->g to NULL instead of removing the kfree().
---
  drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c b/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c
index be83ad9db82a..6207ffe74233 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c
@@ -435,6 +435,7 @@ static int fs_any_create_groups(struct mlx5e_flow_table *ft)
  	in = kvzalloc(inlen, GFP_KERNEL);
  	if  (!in || !ft->g) {
  		kfree(ft->g);
+		ft->g = NULL;
  		kvfree(in);
  		return -ENOMEM;
  	}

Reviewed-by: Tariq Toukan <tariqt@xxxxxxxxxx>






[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux