summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorRoland Dreier <roland@purestorage.com>2015-05-29 23:10:31 -0700
committerDoug Ledford <dledford@redhat.com>2015-06-02 09:22:31 -0400
commit18eaf1f1959add9bbbfa5442fc5d9b59f7d4e1bd (patch)
tree59f5181b652e0425526622f81d820112ce22fe14 /drivers/infiniband
parentd655a9fbc8a51ac8d92db7ff5a599aab17dce3ca (diff)
downloadlinux-18eaf1f1959add9bbbfa5442fc5d9b59f7d4e1bd.tar.bz2
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>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_verbs.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 877175563634..cf1f515efda8 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -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: