Skip to content

Commit

Permalink
RDMA/ocrdma: Fix memory leak in _ocrdma_alloc_pd()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Roland Dreier authored and Doug Ledford committed Jun 2, 2015
1 parent d655a9f commit 18eaf1f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 18eaf1f

Please sign in to comment.