diff mbox series

net/mlx5: prevent memory leak in mlx5_fpga_conn_create_cq

Message ID 20190925032038.22943-1-navid.emamdoost@gmail.com (mailing list archive)
State Not Applicable
Headers show
Series net/mlx5: prevent memory leak in mlx5_fpga_conn_create_cq | expand

Commit Message

Navid Emamdoost Sept. 25, 2019, 3:20 a.m. UTC
In mlx5_fpga_conn_create_cq if mlx5_vector2eqn fails the allocated
memory should be released.

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

Comments

David Miller Sept. 27, 2019, 8:33 a.m. UTC | #1
From: Navid Emamdoost <navid.emamdoost@gmail.com>
Date: Tue, 24 Sep 2019 22:20:34 -0500

> In mlx5_fpga_conn_create_cq if mlx5_vector2eqn fails the allocated
> memory should be released.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

Saeed, please queue this up.
Saeed Mahameed Oct. 15, 2019, 8:35 p.m. UTC | #2
On Fri, 2019-09-27 at 10:33 +0200, David Miller wrote:
> From: Navid Emamdoost <navid.emamdoost@gmail.com>
> Date: Tue, 24 Sep 2019 22:20:34 -0500
> 
> > In mlx5_fpga_conn_create_cq if mlx5_vector2eqn fails the allocated
> > memory should be released.
> > 
> > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> 
> Saeed, please queue this up.

Applied to net-mlx5 branch will send it to net branch shortly.
diff mbox series

Patch

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));