1
0
Fork 0

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: Roland Dreier <roland@purestorage.com>
Acked-By: Devesh Sharma <devesh.sharma@avagotech.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
hifive-unleashed-5.1
Roland Dreier 2015-05-29 23:10:31 -07:00 committed by Doug Ledford
parent d655a9fbc8
commit 18eaf1f195
1 changed files with 6 additions and 1 deletions

View File

@ -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: