diff options
author | Miroslaw Walukiewicz <miroslaw.walukiewicz@intel.com> | 2009-04-21 19:16:48 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2009-04-21 19:16:48 -0400 |
commit | 5d1af5c83232c5a02b9dc0fe43053b4ddc005224 (patch) | |
tree | 705fa258b696855d355fa8ebf2af84ced5f3fa29 /drivers/infiniband | |
parent | cc005fa20c5229c283bea4958869da1e3c8a3720 (diff) |
RDMA/nes: Fix resource issues in nes_create_cq() and nes_destroy_cq()
In error paths where a CQ is not created, pbl is not freeed properly.
In nes_destroy_cq(), add the corresponding check for nescq->mcrqf to
not call nes_free_resource() when it is already done in nes_create_cq().
Signed-off-by: Miroslaw Walukiewicz <miroslaw.walukiewicz@intel.com>
Signed-off-by: Chien Tung <chien.tin.tung@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/nes/nes_verbs.c | 26 | ||||
-rw-r--r-- | drivers/infiniband/hw/nes/nes_verbs.h | 1 |
2 files changed, 26 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index 504e31d9f50c..8b460c2ce892 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c | |||
@@ -1627,6 +1627,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries, | |||
1627 | nescq->hw_cq.cq_number = nes_ucontext->mcrqf & 0xffff; | 1627 | nescq->hw_cq.cq_number = nes_ucontext->mcrqf & 0xffff; |
1628 | else | 1628 | else |
1629 | nescq->hw_cq.cq_number = nesvnic->mcrq_qp_id + nes_ucontext->mcrqf-1; | 1629 | nescq->hw_cq.cq_number = nesvnic->mcrq_qp_id + nes_ucontext->mcrqf-1; |
1630 | nescq->mcrqf = nes_ucontext->mcrqf; | ||
1630 | nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); | 1631 | nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); |
1631 | } | 1632 | } |
1632 | nes_debug(NES_DBG_CQ, "CQ Virtual Address = %08lX, size = %u.\n", | 1633 | nes_debug(NES_DBG_CQ, "CQ Virtual Address = %08lX, size = %u.\n", |
@@ -1682,6 +1683,12 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries, | |||
1682 | if (!context) | 1683 | if (!context) |
1683 | pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, | 1684 | pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, |
1684 | nescq->hw_cq.cq_pbase); | 1685 | nescq->hw_cq.cq_pbase); |
1686 | else { | ||
1687 | pci_free_consistent(nesdev->pcidev, nespbl->pbl_size, | ||
1688 | nespbl->pbl_vbase, nespbl->pbl_pbase); | ||
1689 | kfree(nespbl); | ||
1690 | } | ||
1691 | |||
1685 | nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); | 1692 | nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); |
1686 | kfree(nescq); | 1693 | kfree(nescq); |
1687 | return ERR_PTR(-ENOMEM); | 1694 | return ERR_PTR(-ENOMEM); |
@@ -1705,6 +1712,11 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries, | |||
1705 | if (!context) | 1712 | if (!context) |
1706 | pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, | 1713 | pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, |
1707 | nescq->hw_cq.cq_pbase); | 1714 | nescq->hw_cq.cq_pbase); |
1715 | else { | ||
1716 | pci_free_consistent(nesdev->pcidev, nespbl->pbl_size, | ||
1717 | nespbl->pbl_vbase, nespbl->pbl_pbase); | ||
1718 | kfree(nespbl); | ||
1719 | } | ||
1708 | nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); | 1720 | nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); |
1709 | kfree(nescq); | 1721 | kfree(nescq); |
1710 | return ERR_PTR(-ENOMEM); | 1722 | return ERR_PTR(-ENOMEM); |
@@ -1722,6 +1734,11 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries, | |||
1722 | if (!context) | 1734 | if (!context) |
1723 | pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, | 1735 | pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, |
1724 | nescq->hw_cq.cq_pbase); | 1736 | nescq->hw_cq.cq_pbase); |
1737 | else { | ||
1738 | pci_free_consistent(nesdev->pcidev, nespbl->pbl_size, | ||
1739 | nespbl->pbl_vbase, nespbl->pbl_pbase); | ||
1740 | kfree(nespbl); | ||
1741 | } | ||
1725 | nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); | 1742 | nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); |
1726 | kfree(nescq); | 1743 | kfree(nescq); |
1727 | return ERR_PTR(-ENOMEM); | 1744 | return ERR_PTR(-ENOMEM); |
@@ -1774,6 +1791,11 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries, | |||
1774 | if (!context) | 1791 | if (!context) |
1775 | pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, | 1792 | pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, |
1776 | nescq->hw_cq.cq_pbase); | 1793 | nescq->hw_cq.cq_pbase); |
1794 | else { | ||
1795 | pci_free_consistent(nesdev->pcidev, nespbl->pbl_size, | ||
1796 | nespbl->pbl_vbase, nespbl->pbl_pbase); | ||
1797 | kfree(nespbl); | ||
1798 | } | ||
1777 | nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); | 1799 | nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); |
1778 | kfree(nescq); | 1800 | kfree(nescq); |
1779 | return ERR_PTR(-EIO); | 1801 | return ERR_PTR(-EIO); |
@@ -1855,7 +1877,9 @@ static int nes_destroy_cq(struct ib_cq *ib_cq) | |||
1855 | set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_OPCODE_IDX, opcode); | 1877 | set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_OPCODE_IDX, opcode); |
1856 | set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_ID_IDX, | 1878 | set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_ID_IDX, |
1857 | (nescq->hw_cq.cq_number | ((u32)PCI_FUNC(nesdev->pcidev->devfn) << 16))); | 1879 | (nescq->hw_cq.cq_number | ((u32)PCI_FUNC(nesdev->pcidev->devfn) << 16))); |
1858 | nes_free_resource(nesadapter, nesadapter->allocated_cqs, nescq->hw_cq.cq_number); | 1880 | if (!nescq->mcrqf) |
1881 | nes_free_resource(nesadapter, nesadapter->allocated_cqs, nescq->hw_cq.cq_number); | ||
1882 | |||
1859 | atomic_set(&cqp_request->refcount, 2); | 1883 | atomic_set(&cqp_request->refcount, 2); |
1860 | nes_post_cqp_request(nesdev, cqp_request); | 1884 | nes_post_cqp_request(nesdev, cqp_request); |
1861 | 1885 | ||
diff --git a/drivers/infiniband/hw/nes/nes_verbs.h b/drivers/infiniband/hw/nes/nes_verbs.h index 5e48f67fbe8d..41c07f29f7c9 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.h +++ b/drivers/infiniband/hw/nes/nes_verbs.h | |||
@@ -112,6 +112,7 @@ struct nes_cq { | |||
112 | spinlock_t lock; | 112 | spinlock_t lock; |
113 | u8 virtual_cq; | 113 | u8 virtual_cq; |
114 | u8 pad[3]; | 114 | u8 pad[3]; |
115 | u32 mcrqf; | ||
115 | }; | 116 | }; |
116 | 117 | ||
117 | struct nes_wq { | 118 | struct nes_wq { |