diff mbox series

net/mlx5e: Fix memleak in mlx5e_create_l2_table_groups

Message ID 20201221112731.32545-1-dinghao.liu@zju.edu.cn
State New
Headers show
Series net/mlx5e: Fix memleak in mlx5e_create_l2_table_groups | expand

Commit Message

Dinghao Liu Dec. 21, 2020, 11:27 a.m. UTC
When mlx5_create_flow_group() fails, ft->g should be
freed just like when kvzalloc() fails. The caller of
mlx5e_create_l2_table_groups() does not catch this
issue on failure, which leads to memleak.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Leon Romanovsky Dec. 27, 2020, 8:33 a.m. UTC | #1
On Mon, Dec 21, 2020 at 07:27:31PM +0800, Dinghao Liu wrote:
> When mlx5_create_flow_group() fails, ft->g should be

> freed just like when kvzalloc() fails. The caller of

> mlx5e_create_l2_table_groups() does not catch this

> issue on failure, which leads to memleak.

>

> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>

> ---

>  drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 1 +

>  1 file changed, 1 insertion(+)

>


Fixes: 33cfaaa8f36f ("net/mlx5e: Split the main flow steering table")

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Saeed Mahameed Jan. 5, 2021, 9:04 p.m. UTC | #2
On Sun, 2020-12-27 at 10:33 +0200, Leon Romanovsky wrote:
> On Mon, Dec 21, 2020 at 07:27:31PM +0800, Dinghao Liu wrote:

> > When mlx5_create_flow_group() fails, ft->g should be

> > freed just like when kvzalloc() fails. The caller of

> > mlx5e_create_l2_table_groups() does not catch this

> > issue on failure, which leads to memleak.

> > 

> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>

> > ---

> >  drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 1 +

> >  1 file changed, 1 insertion(+)

> > 

> 

> Fixes: 33cfaaa8f36f ("net/mlx5e: Split the main flow steering table")

> 

Added

> Thanks,

> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>


Applied to net-mlx5
Thanks
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
index fa8149f6eb08..72de1009b104 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
@@ -1390,6 +1390,7 @@  static int mlx5e_create_l2_table_groups(struct mlx5e_l2_table *l2_table)
 	ft->g[ft->num_groups] = NULL;
 	mlx5e_destroy_groups(ft);
 	kvfree(in);
+	kfree(ft->g);
 
 	return err;
 }