From: Roland Dreier Date: Thu, 28 Sep 2006 17:44:07 +0000 (-0700) Subject: RDMA/amso1100: Fix memory leak in c2_reg_phys_mr() X-Git-Tag: v2.6.19-rc1~652^2~30 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=ee30cb5b0b65392843cc3beaba48160ee4a3764e;p=linux-2.6-omap-h63xx.git RDMA/amso1100: Fix memory leak in c2_reg_phys_mr() If the allocation of mr fails, then c2_reg_phys_mr() leaks the page_list array it allocated earlier. This was Coverity CID #1413. Signed-off-by: Roland Dreier --- diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c index 622d6f1f920..da98d9f7142 100644 --- a/drivers/infiniband/hw/amso1100/c2_provider.c +++ b/drivers/infiniband/hw/amso1100/c2_provider.c @@ -390,8 +390,10 @@ static struct ib_mr *c2_reg_phys_mr(struct ib_pd *ib_pd, } mr = kmalloc(sizeof(*mr), GFP_KERNEL); - if (!mr) + if (!mr) { + vfree(page_list); return ERR_PTR(-ENOMEM); + } mr->pd = to_c2pd(ib_pd); pr_debug("%s - page shift %d, pbl_depth %d, total_len %u, "