[PATCH] net/mlx5: prevent memory leak in mlx5_fpga_conn_create_cq

From: Navid Emamdoost
Date: Tue Sep 24 2019 - 23:20:55 EST


In mlx5_fpga_conn_create_cq if mlx5_vector2eqn fails the allocated
memory should be released.

Signed-off-by: Navid Emamdoost <navid.emamdoost@xxxxxxxxx>
---
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
index 4c50efe4e7f1..61021133029e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
@@ -464,8 +464,10 @@ static int mlx5_fpga_conn_create_cq(struct mlx5_fpga_conn *conn, int cq_size)
}

err = mlx5_vector2eqn(mdev, smp_processor_id(), &eqn, &irqn);
- if (err)
+ if (err) {
+ kvfree(in);
goto err_cqwq;
+ }

cqc = MLX5_ADDR_OF(create_cq_in, in, cq_context);
MLX5_SET(cqc, cqc, log_cq_size, ilog2(cq_size));
--
2.17.1