Skip to content

Commit

Permalink
IB/hns: fix memory leak on ah on error return path
Browse files Browse the repository at this point in the history
When dmac is NULL, ah is not being freed on the error return path. Fix
this by kfree'ing it.

Detected by CoverityScan, CID#1452636 ("Resource Leak")

Fixes: d8966fc ("IB/core: Use rdma_ah_attr accessor functions")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
Colin Ian King authored and Doug Ledford committed Aug 16, 2017
1 parent aa939c1 commit 5b59a39
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/infiniband/hw/hns/hns_roce_ah.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd *ibpd,
} else {
u8 *dmac = rdma_ah_retrieve_dmac(ah_attr);

if (!dmac)
if (!dmac) {
kfree(ah);
return ERR_PTR(-EINVAL);
}
memcpy(ah->av.mac, dmac, ETH_ALEN);
}

Expand Down

0 comments on commit 5b59a39

Please sign in to comment.