From: Chiara Meiohas <cmeiohas@nvidia.com>
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>
---
drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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.31.1
… > +++ 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) Can an other order become more appropriate for the items of this condition check? > + return 0; > > if (err > 0) /* Failed in FW, command didn't execute */ > err = deliv_status_to_err(err); Regards, Markus
On Thu, Jul 17, 2025 at 03:06:09PM +0300, Tariq Toukan wrote:
> From: Chiara Meiohas <cmeiohas@nvidia.com>
>
> 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>
© 2016 - 2025 Red Hat, Inc.