Netdev List
 help / color / mirror / Atom feed
From: Tariq Toukan <tariqt@nvidia.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, <netdev@vger.kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>
Cc: Gal Pressman <gal@nvidia.com>, Jianbo Liu <jianbol@nvidia.com>,
	"Leon Romanovsky" <leon@kernel.org>, <linux-rdma@vger.kernel.org>,
	Mark Bloch <mbloch@nvidia.com>, Oz Shlomo <ozsh@nvidia.com>,
	Roi Dayan <roid@nvidia.com>, Saeed Mahameed <saeedm@nvidia.com>,
	Tariq Toukan <tariqt@nvidia.com>
Subject: [PATCH net] net/mlx5e: TC, Fix parse_attr leak on branch attr alloc failure
Date: Thu, 26 Nov 2026 14:23:16 +0200	[thread overview]
Message-ID: <20261126122316.599831-1-tariqt@nvidia.com> (raw)

alloc_branch_attr() gets the branch attribute from
mlx5e_clone_flow_attr_for_post_act(), which also allocates its
parse_attr. When the branch action cannot be offloaded, the error path
frees the attribute but not its parse_attr, leaking it.

This happens, for example, when a police action's conform and exceed
actions are both jumps: the exceed action fails with "Cannot offload
flows with nested jumps".

Free the parse_attr too.

Found by LLM-assisted code inspection, while reviewing a fix for a
double free on the same error path.

Reproduced on ConnectX-6 Dx in switchdev mode, with kmemleak, by
failing 50 times to offload such a filter on the uplink representor:

  tc filter add dev $UPLINK ingress protocol ip flower skip_sw \
          dst_ip 192.0.2.2 action police rate 1mbit burst 20k \
          conform-exceed jump 1 / jump 1 action pass action drop

Without this patch, kmemleak reported 29 unreferenced 4096-byte
objects, all allocated by mlx5e_clone_flow_attr_for_post_act() from
alloc_branch_attr(). With it, kmemleak reported none.

Fixes: f86488cb4685 ("net/mlx5e: TC, initialize branch flow attributes")
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Jianbo Liu <jianbol@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 011741553f5b..142cccba907e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -3915,7 +3915,8 @@ alloc_branch_attr(struct mlx5e_tc_flow *flow,
 
 	return err;
 out_err:
-	kfree(*cond_attr);
+	kvfree(attr->parse_attr);
+	kfree(attr);
 	*cond_attr = NULL;
 	return err;
 }

base-commit: cc7fe6e741730fef549e484379281736d32746f0
-- 
2.44.0


                 reply	other threads:[~2026-11-26 12:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261126122316.599831-1-tariqt@nvidia.com \
    --to=tariqt@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=gal@nvidia.com \
    --cc=jianbol@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=ozsh@nvidia.com \
    --cc=pabeni@redhat.com \
    --cc=roid@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=willemb@google.com \
    /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