Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b59a396 authored by Colin Ian King's avatar Colin Ian King Committed by Doug Ledford
Browse files

IB/hns: fix memory leak on ah on error return path



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: d8966fcd ("IB/core: Use rdma_ah_attr accessor functions")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent aa939c12
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -64,8 +64,10 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd *ibpd,
	} else {
	} else {
		u8 *dmac = rdma_ah_retrieve_dmac(ah_attr);
		u8 *dmac = rdma_ah_retrieve_dmac(ah_attr);


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