[PATCH] IB: mlx4: Fix mem leaks in ib_link_query_port()

From: Jesper Juhl
Date: Wed Apr 11 2012 - 17:43:32 EST


If, in ib_link_query_port(), the call to mlx4_MAD_IFC() fails we will
currently do 'return err;' which will leak 'in_mad' and 'out_mad' that
we previously allocated. I believe we should instead do 'goto out;'
where we'll properly free the memory we previously allocated.

Signed-off-by: Jesper Juhl <jj@xxxxxxxxxxxxx>
---
drivers/infiniband/hw/mlx4/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 75d3056..cc88c9c 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -247,7 +247,7 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
err = mlx4_MAD_IFC(to_mdev(ibdev), 1, 1, port,
NULL, NULL, in_mad, out_mad);
if (err)
- return err;
+ goto out;

/* Checking LinkSpeedActive for FDR-10 */
if (out_mad->data[15] & 0x1)
--
1.7.10


--
Jesper Juhl <jj@xxxxxxxxxxxxx> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/