IB/mlx4: Fix memory leaks in ib_link_query_port()
authorJesper Juhl <jj@chaosbits.net>
Wed, 11 Apr 2012 21:43:29 +0000 (23:43 +0200)
committerRoland Dreier <roland@purestorage.com>
Tue, 24 Apr 2012 23:11:21 +0000 (16:11 -0700)
If the call to mlx4_MAD_IFC() fails in ib_link_query_port() we will
currently do 'return err;' which will leak 'in_mad' and 'out_mad'.  We
should instead do 'goto out;' where we'll properly free the memory we
previously allocated.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/mlx4/main.c

index 75d30562930058b14dd38700e3fe441f3bdcc796..cc88c9c955c937c06c279f06d33c523ad864a96e 100644 (file)
@@ -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)