Unverified Commit 0488a59f authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!7853 net/mlx5e: fix a double-free in arfs_create_groups

parents c8ab1a53 000d00a1
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -214,11 +214,13 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,

	ft->g = kcalloc(MLX5E_ARFS_NUM_GROUPS,
			sizeof(*ft->g), GFP_KERNEL);
	in = kvzalloc(inlen, GFP_KERNEL);
	if  (!in || !ft->g) {
		kfree(ft->g);
		kvfree(in);
	if (!ft->g)
		return -ENOMEM;

	in = kvzalloc(inlen, GFP_KERNEL);
	if (!in) {
		err = -ENOMEM;
		goto err_free_g;
	}

	mc = MLX5_ADDR_OF(create_flow_group_in, in, match_criteria);
@@ -238,7 +240,7 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
		break;
	default:
		err = -EINVAL;
		goto out;
		goto err_free_in;
	}

	switch (type) {
@@ -260,7 +262,7 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
		break;
	default:
		err = -EINVAL;
		goto out;
		goto err_free_in;
	}

	MLX5_SET_CFG(in, match_criteria_enable, MLX5_MATCH_OUTER_HEADERS);
@@ -269,7 +271,7 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
	MLX5_SET_CFG(in, end_flow_index, ix - 1);
	ft->g[ft->num_groups] = mlx5_create_flow_group(ft->t, in);
	if (IS_ERR(ft->g[ft->num_groups]))
		goto err;
		goto err_clean_group;
	ft->num_groups++;

	memset(in, 0, inlen);
@@ -278,18 +280,20 @@ static int arfs_create_groups(struct mlx5e_flow_table *ft,
	MLX5_SET_CFG(in, end_flow_index, ix - 1);
	ft->g[ft->num_groups] = mlx5_create_flow_group(ft->t, in);
	if (IS_ERR(ft->g[ft->num_groups]))
		goto err;
		goto err_clean_group;
	ft->num_groups++;

	kvfree(in);
	return 0;

err:
err_clean_group:
	err = PTR_ERR(ft->g[ft->num_groups]);
	ft->g[ft->num_groups] = NULL;
out:
err_free_in:
	kvfree(in);

err_free_g:
	kfree(ft->g);
	ft->g = NULL;
	return err;
}