From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Jianbo Liu <jianbol@mellanox.com>,
Saeed Mahameed <saeedm@mellanox.com>
Subject: [net 6/8] net/mlx5e: Fix memory usage issues in offloading TC flows
Date: Fri, 23 Mar 2018 15:05:32 -0700 [thread overview]
Message-ID: <20180323220534.19353-7-saeedm@mellanox.com> (raw)
In-Reply-To: <20180323220534.19353-1-saeedm@mellanox.com>
From: Jianbo Liu <jianbol@mellanox.com>
For NIC flows, the parsed attributes are not freed when we exit
successfully from mlx5e_configure_flower().
There is possible double free for eswitch flows. If error is returned
from rhashtable_insert_fast(), the parse attrs will be freed in
mlx5e_tc_del_flow(), but they will be freed again before exiting
mlx5e_configure_flower().
To fix both issues we do the following:
(1) change the condition that determines if to issue the free call to
check if this flow is NIC flow, or it does not have encap action.
(2) reorder the code such that that the check and free calls are done
before we attempt to add into the hash table.
Fixes: 232c001398ae ('net/mlx5e: Add support to neighbour update flow')
Signed-off-by: Jianbo Liu <jianbol@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index fa86a1466718..ae11678a31e8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -2608,19 +2608,19 @@ int mlx5e_configure_flower(struct mlx5e_priv *priv,
if (err != -EAGAIN)
flow->flags |= MLX5E_TC_FLOW_OFFLOADED;
+ if (!(flow->flags & MLX5E_TC_FLOW_ESWITCH) ||
+ !(flow->esw_attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP))
+ kvfree(parse_attr);
+
err = rhashtable_insert_fast(&tc->ht, &flow->node,
tc->ht_params);
- if (err)
- goto err_del_rule;
+ if (err) {
+ mlx5e_tc_del_flow(priv, flow);
+ kfree(flow);
+ }
- if (flow->flags & MLX5E_TC_FLOW_ESWITCH &&
- !(flow->esw_attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP))
- kvfree(parse_attr);
return err;
-err_del_rule:
- mlx5e_tc_del_flow(priv, flow);
-
err_free:
kvfree(parse_attr);
kfree(flow);
--
2.14.3
next prev parent reply other threads:[~2018-03-23 22:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-23 22:05 [pull request][net 0/8] Mellanox, mlx5 fixes 2018-03-23 Saeed Mahameed
2018-03-23 22:05 ` [net 1/8] net/mlx5e: Don't override vport admin link state in switchdev mode Saeed Mahameed
2018-03-23 22:05 ` [net 2/8] net/mlx5e: Use 32 bits to store VF representor SQ number Saeed Mahameed
2018-03-23 22:05 ` [net 3/8] net/mlx5: Make eswitch support to depend on switchdev Saeed Mahameed
2018-03-23 22:05 ` [net 4/8] net/mlx5e: Verify coalescing parameters in range Saeed Mahameed
2018-03-23 22:05 ` [net 5/8] net/mlx5e: Fix traffic being dropped on VF representor Saeed Mahameed
2018-03-23 22:05 ` Saeed Mahameed [this message]
2018-03-23 22:05 ` [net 7/8] net/mlx5e: Avoid using the ipv6 stub in the TC offload neigh update path Saeed Mahameed
2018-03-24 9:52 ` Sergei Shtylyov
2018-03-23 22:05 ` [net 8/8] net/mlx5e: Sync netdev vxlan ports at open Saeed Mahameed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180323220534.19353-7-saeedm@mellanox.com \
--to=saeedm@mellanox.com \
--cc=davem@davemloft.net \
--cc=jianbol@mellanox.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox