diff options
author | Talat Batheesh <talatb@mellanox.com> | 2018-08-30 09:31:52 -0400 |
---|---|---|
committer | Saeed Mahameed <saeedm@mellanox.com> | 2018-10-10 21:26:15 -0400 |
commit | fd7e848077c1a466b9187537adce16658f7cb94b (patch) | |
tree | e16681deed1f5d8b201fb9f073e61926e011fafd | |
parent | 52b5d6f5dcf0e5201392f7d417148ccb537dbf6f (diff) |
net/mlx5: Fix memory leak when setting fpga ipsec caps
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>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c index 5645a4facad2..b8ee9101c506 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | |||
@@ -245,7 +245,7 @@ static void *mlx5_fpga_ipsec_cmd_exec(struct mlx5_core_dev *mdev, | |||
245 | return ERR_PTR(res); | 245 | return ERR_PTR(res); |
246 | } | 246 | } |
247 | 247 | ||
248 | /* Context will be freed by wait func after completion */ | 248 | /* Context should be freed by the caller after completion. */ |
249 | return context; | 249 | return context; |
250 | } | 250 | } |
251 | 251 | ||
@@ -418,10 +418,8 @@ static int mlx5_fpga_ipsec_set_caps(struct mlx5_core_dev *mdev, u32 flags) | |||
418 | cmd.cmd = htonl(MLX5_FPGA_IPSEC_CMD_OP_SET_CAP); | 418 | cmd.cmd = htonl(MLX5_FPGA_IPSEC_CMD_OP_SET_CAP); |
419 | cmd.flags = htonl(flags); | 419 | cmd.flags = htonl(flags); |
420 | context = mlx5_fpga_ipsec_cmd_exec(mdev, &cmd, sizeof(cmd)); | 420 | context = mlx5_fpga_ipsec_cmd_exec(mdev, &cmd, sizeof(cmd)); |
421 | if (IS_ERR(context)) { | 421 | if (IS_ERR(context)) |
422 | err = PTR_ERR(context); | 422 | return PTR_ERR(context); |
423 | goto out; | ||
424 | } | ||
425 | 423 | ||
426 | err = mlx5_fpga_ipsec_cmd_wait(context); | 424 | err = mlx5_fpga_ipsec_cmd_wait(context); |
427 | if (err) | 425 | if (err) |
@@ -435,6 +433,7 @@ static int mlx5_fpga_ipsec_set_caps(struct mlx5_core_dev *mdev, u32 flags) | |||
435 | } | 433 | } |
436 | 434 | ||
437 | out: | 435 | out: |
436 | kfree(context); | ||
438 | return err; | 437 | return err; |
439 | } | 438 | } |
440 | 439 | ||