Commit 18eaf1f1 authored by Roland Dreier's avatar Roland Dreier Committed by Doug Ledford

RDMA/ocrdma: Fix memory leak in _ocrdma_alloc_pd()

If ocrdma_get_pd_num() fails, then we need to free the pd struct we allocated.

This was detected by Coverity (CID 1271245).
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
Acked-By: default avatarDevesh Sharma <devesh.sharma@avagotech.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent d655a9fb
......@@ -375,7 +375,12 @@ static struct ocrdma_pd *_ocrdma_alloc_pd(struct ocrdma_dev *dev,
if (dev->pd_mgr->pd_prealloc_valid) {
status = ocrdma_get_pd_num(dev, pd);
return (status == 0) ? pd : ERR_PTR(status);
if (status == 0) {
return pd;
} else {
kfree(pd);
return ERR_PTR(status);
}
}
retry:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment