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>
This commit is contained in:
Roland Dreier 2015-05-29 23:10:31 -07:00 коммит произвёл Doug Ledford
Родитель d655a9fbc8
Коммит 18eaf1f195
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

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