Blame SOURCES/0247-netdrv-net-mlx5e-CT-Fix-stack-usage-compiler-warning.patch

d8f823
From cb2edef541ca9dba7f68efc459869b5d47665dd6 Mon Sep 17 00:00:00 2001
d8f823
From: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Date: Tue, 19 May 2020 07:49:09 -0400
d8f823
Subject: [PATCH 247/312] [netdrv] net/mlx5e: CT: Fix stack usage compiler
d8f823
 warning
d8f823
MIME-Version: 1.0
d8f823
Content-Type: text/plain; charset=UTF-8
d8f823
Content-Transfer-Encoding: 8bit
d8f823
d8f823
Message-id: <20200519074934.6303-39-ahleihel@redhat.com>
d8f823
Patchwork-id: 310541
d8f823
Patchwork-instance: patchwork
d8f823
O-Subject: [RHEL8.3 BZ 1663246 38/63] net/mlx5e: CT: Fix stack usage compiler warning
d8f823
Bugzilla: 1663246
d8f823
RH-Acked-by: Marcelo Leitner <mleitner@redhat.com>
d8f823
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
d8f823
RH-Acked-by: John Linville <linville@redhat.com>
d8f823
RH-Acked-by: Ivan Vecera <ivecera@redhat.com>
d8f823
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
d8f823
RH-Acked-by: Kamal Heib <kheib@redhat.com>
d8f823
d8f823
Bugzilla: http://bugzilla.redhat.com/1663246
d8f823
Upstream: v5.7-rc1
d8f823
d8f823
commit aded104d397c22a18b9040f5641309f426d6df27
d8f823
Author: Saeed Mahameed <saeedm@mellanox.com>
d8f823
Date:   Mon Mar 16 15:47:03 2020 -0700
d8f823
d8f823
    net/mlx5e: CT: Fix stack usage compiler warning
d8f823
d8f823
    Fix the following warnings: [-Werror=frame-larger-than=]
d8f823
d8f823
    In function ‘mlx5_tc_ct_entry_add_rule’:
d8f823
    drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c:541:1:
d8f823
    error: the frame size of 1136 bytes is larger than 1024 bytes
d8f823
d8f823
    In function ‘__mlx5_tc_ct_flow_offload’:
d8f823
    drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c:1049:1:
d8f823
    error: the frame size of 1168 bytes is larger than 1024 bytes
d8f823
d8f823
    Fixes: 4c3844d9e97e ("net/mlx5e: CT: Introduce connection tracking")
d8f823
    Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
d8f823
    Reviewed-by: Paul Blakey <paulb@mellanox.com>
d8f823
d8f823
Signed-off-by: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
d8f823
---
d8f823
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 31 +++++++++++++++-------
d8f823
 1 file changed, 22 insertions(+), 9 deletions(-)
d8f823
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
d8f823
index 956d9ddcdeed..cb43b53bc235 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
d8f823
@@ -484,19 +484,23 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
d8f823
 	struct mlx5_ct_zone_rule *zone_rule = &entry->zone_rules[nat];
d8f823
 	struct mlx5_esw_flow_attr *attr = &zone_rule->attr;
d8f823
 	struct mlx5_eswitch *esw = ct_priv->esw;
d8f823
-	struct mlx5_flow_spec spec = {};
d8f823
+	struct mlx5_flow_spec *spec = NULL;
d8f823
 	u32 tupleid = 1;
d8f823
 	int err;
d8f823
 
d8f823
 	zone_rule->nat = nat;
d8f823
 
d8f823
+	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
d8f823
+	if (!spec)
d8f823
+		return -ENOMEM;
d8f823
+
d8f823
 	/* Get tuple unique id */
d8f823
 	err = idr_alloc_u32(&ct_priv->tuple_ids, zone_rule, &tupleid,
d8f823
 			    TUPLE_ID_MAX, GFP_KERNEL);
d8f823
 	if (err) {
d8f823
 		netdev_warn(ct_priv->netdev,
d8f823
 			    "Failed to allocate tuple id, err: %d\n", err);
d8f823
-		return err;
d8f823
+		goto err_idr_alloc;
d8f823
 	}
d8f823
 	zone_rule->tupleid = tupleid;
d8f823
 
d8f823
@@ -517,18 +521,19 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
d8f823
 	attr->counter = entry->counter;
d8f823
 	attr->flags |= MLX5_ESW_ATTR_FLAG_NO_IN_PORT;
d8f823
 
d8f823
-	mlx5_tc_ct_set_tuple_match(&spec, flow_rule);
d8f823
-	mlx5e_tc_match_to_reg_match(&spec, ZONE_TO_REG,
d8f823
+	mlx5_tc_ct_set_tuple_match(spec, flow_rule);
d8f823
+	mlx5e_tc_match_to_reg_match(spec, ZONE_TO_REG,
d8f823
 				    entry->zone & MLX5_CT_ZONE_MASK,
d8f823
 				    MLX5_CT_ZONE_MASK);
d8f823
 
d8f823
-	zone_rule->rule = mlx5_eswitch_add_offloaded_rule(esw, &spec, attr);
d8f823
+	zone_rule->rule = mlx5_eswitch_add_offloaded_rule(esw, spec, attr);
d8f823
 	if (IS_ERR(zone_rule->rule)) {
d8f823
 		err = PTR_ERR(zone_rule->rule);
d8f823
 		ct_dbg("Failed to add ct entry rule, nat: %d", nat);
d8f823
 		goto err_rule;
d8f823
 	}
d8f823
 
d8f823
+	kfree(spec);
d8f823
 	ct_dbg("Offloaded ct entry rule in zone %d", entry->zone);
d8f823
 
d8f823
 	return 0;
d8f823
@@ -537,6 +542,8 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
d8f823
 	mlx5_modify_header_dealloc(esw->dev, attr->modify_hdr);
d8f823
 err_mod_hdr:
d8f823
 	idr_remove(&ct_priv->tuple_ids, zone_rule->tupleid);
d8f823
+err_idr_alloc:
d8f823
+	kfree(spec);
d8f823
 	return err;
d8f823
 }
d8f823
 
d8f823
@@ -885,8 +892,8 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
d8f823
 	struct mlx5_tc_ct_priv *ct_priv = mlx5_tc_ct_get_ct_priv(priv);
d8f823
 	bool nat = attr->ct_attr.ct_action & TCA_CT_ACT_NAT;
d8f823
 	struct mlx5e_tc_mod_hdr_acts pre_mod_acts = {};
d8f823
+	struct mlx5_flow_spec *post_ct_spec = NULL;
d8f823
 	struct mlx5_eswitch *esw = ct_priv->esw;
d8f823
-	struct mlx5_flow_spec post_ct_spec = {};
d8f823
 	struct mlx5_esw_flow_attr *pre_ct_attr;
d8f823
 	struct  mlx5_modify_hdr *mod_hdr;
d8f823
 	struct mlx5_flow_handle *rule;
d8f823
@@ -895,9 +902,13 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
d8f823
 	struct mlx5_ct_ft *ft;
d8f823
 	u32 fte_id = 1;
d8f823
 
d8f823
+	post_ct_spec = kzalloc(sizeof(*post_ct_spec), GFP_KERNEL);
d8f823
 	ct_flow = kzalloc(sizeof(*ct_flow), GFP_KERNEL);
d8f823
-	if (!ct_flow)
d8f823
+	if (!post_ct_spec || !ct_flow) {
d8f823
+		kfree(post_ct_spec);
d8f823
+		kfree(ct_flow);
d8f823
 		return -ENOMEM;
d8f823
+	}
d8f823
 
d8f823
 	/* Register for CT established events */
d8f823
 	ft = mlx5_tc_ct_add_ft_cb(ct_priv, attr->ct_attr.zone,
d8f823
@@ -992,7 +1003,7 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
d8f823
 	/* Post ct rule matches on fte_id and executes original rule's
d8f823
 	 * tc rule action
d8f823
 	 */
d8f823
-	mlx5e_tc_match_to_reg_match(&post_ct_spec, FTEID_TO_REG,
d8f823
+	mlx5e_tc_match_to_reg_match(post_ct_spec, FTEID_TO_REG,
d8f823
 				    fte_id, MLX5_FTE_ID_MASK);
d8f823
 
d8f823
 	/* Put post_ct rule on post_ct fdb */
d8f823
@@ -1003,7 +1014,7 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
d8f823
 	ct_flow->post_ct_attr.inner_match_level = MLX5_MATCH_NONE;
d8f823
 	ct_flow->post_ct_attr.outer_match_level = MLX5_MATCH_NONE;
d8f823
 	ct_flow->post_ct_attr.action &= ~(MLX5_FLOW_CONTEXT_ACTION_DECAP);
d8f823
-	rule = mlx5_eswitch_add_offloaded_rule(esw, &post_ct_spec,
d8f823
+	rule = mlx5_eswitch_add_offloaded_rule(esw, post_ct_spec,
d8f823
 					       &ct_flow->post_ct_attr);
d8f823
 	ct_flow->post_ct_rule = rule;
d8f823
 	if (IS_ERR(ct_flow->post_ct_rule)) {
d8f823
@@ -1027,6 +1038,7 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
d8f823
 	attr->ct_attr.ct_flow = ct_flow;
d8f823
 	*flow_rule = ct_flow->post_ct_rule;
d8f823
 	dealloc_mod_hdr_actions(&pre_mod_acts);
d8f823
+	kfree(post_ct_spec);
d8f823
 
d8f823
 	return 0;
d8f823
 
d8f823
@@ -1043,6 +1055,7 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
d8f823
 err_idr:
d8f823
 	mlx5_tc_ct_del_ft_cb(ct_priv, ft);
d8f823
 err_ft:
d8f823
+	kfree(post_ct_spec);
d8f823
 	kfree(ct_flow);
d8f823
 	netdev_warn(priv->netdev, "Failed to offload ct flow, err %d\n", err);
d8f823
 	return err;
d8f823
-- 
d8f823
2.13.6
d8f823