From: Jesper Juhl Date: Wed, 11 Apr 2012 21:43:29 +0000 (+0200) Subject: IB/mlx4: Fix memory leaks in ib_link_query_port() X-Git-Tag: upstream/snapshot3+hdmi~7614^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf6b47deb40f9fc8ddb4573373dc9614aab59d35;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git IB/mlx4: Fix memory leaks in ib_link_query_port() 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 Acked-by: Or Gerlitz Signed-off-by: Roland Dreier --- 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)