50 lines
1.9 KiB
Diff
50 lines
1.9 KiB
Diff
From 0e6b8d1b57695231dc16f426ca329c7fc415ff43 Mon Sep 17 00:00:00 2001
|
|
From: Kamal Heib <kheib@redhat.com>
|
|
Date: Thu, 16 Apr 2026 17:42:12 -0400
|
|
Subject: [PATCH] net/mlx5: Fix memory leak in cmd_exec()
|
|
|
|
JIRA: https://redhat.atlassian.net/browse/RHEL-169055
|
|
|
|
commit 3afa3ae3db52e3c216d77bd5907a5a86833806cc
|
|
Author: Chiara Meiohas <cmeiohas@nvidia.com>
|
|
Date: Thu Jul 17 15:06:09 2025 +0300
|
|
|
|
net/mlx5: Fix memory leak in cmd_exec()
|
|
|
|
If cmd_exec() is called with callback and mlx5_cmd_invoke() returns an
|
|
error, resources allocated in cmd_exec() will not be freed.
|
|
|
|
Fix the code to release the resources if mlx5_cmd_invoke() returns an
|
|
error.
|
|
|
|
Fixes: f086470122d5 ("net/mlx5: cmdif, Return value improvements")
|
|
Reported-by: Alex Tereshkin <atereshkin@nvidia.com>
|
|
Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
|
|
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
|
|
Signed-off-by: Vlad Dumitrescu <vdumitrescu@nvidia.com>
|
|
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
|
|
Reviewed-by: Simon Horman <horms@kernel.org>
|
|
Link: https://patch.msgid.link/1752753970-261832-2-git-send-email-tariqt@nvidia.com
|
|
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
|
|
Signed-off-by: Kamal Heib <kheib@redhat.com>
|
|
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
|
|
index b1aeea7c4a91..e395ef5f356e 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
|
|
@@ -1947,8 +1947,8 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
|
|
|
|
err = mlx5_cmd_invoke(dev, inb, outb, out, out_size, callback, context,
|
|
pages_queue, token, force_polling);
|
|
- if (callback)
|
|
- return err;
|
|
+ if (callback && !err)
|
|
+ return 0;
|
|
|
|
if (err > 0) /* Failed in FW, command didn't execute */
|
|
err = deliv_status_to_err(err);
|
|
--
|
|
2.50.1 (Apple Git-155)
|
|
|