]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net/mlx5: Fix memory leak when setting fpga ipsec caps
authorTalat Batheesh <talatb@mellanox.com>
Thu, 30 Aug 2018 13:31:52 +0000 (16:31 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Thu, 11 Oct 2018 01:26:15 +0000 (18:26 -0700)
Allocated memory for context should be freed once
finished working with it.

Fixes: d6c4f0298cec ("net/mlx5: Refactor accel IPSec code")
Signed-off-by: Talat Batheesh <talatb@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c

index 5645a4facad2f3e5cc1a4a48553e6f83142e72dc..b8ee9101c5066fba94c27d5600aa3a632cff33ca 100644 (file)
@@ -245,7 +245,7 @@ static void *mlx5_fpga_ipsec_cmd_exec(struct mlx5_core_dev *mdev,
                return ERR_PTR(res);
        }
 
-       /* Context will be freed by wait func after completion */
+       /* Context should be freed by the caller after completion. */
        return context;
 }
 
@@ -418,10 +418,8 @@ static int mlx5_fpga_ipsec_set_caps(struct mlx5_core_dev *mdev, u32 flags)
        cmd.cmd = htonl(MLX5_FPGA_IPSEC_CMD_OP_SET_CAP);
        cmd.flags = htonl(flags);
        context = mlx5_fpga_ipsec_cmd_exec(mdev, &cmd, sizeof(cmd));
-       if (IS_ERR(context)) {
-               err = PTR_ERR(context);
-               goto out;
-       }
+       if (IS_ERR(context))
+               return PTR_ERR(context);
 
        err = mlx5_fpga_ipsec_cmd_wait(context);
        if (err)
@@ -435,6 +433,7 @@ static int mlx5_fpga_ipsec_set_caps(struct mlx5_core_dev *mdev, u32 flags)
        }
 
 out:
+       kfree(context);
        return err;
 }