aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorDennis Dalessandro <dennis.dalessandro@intel.com>2014-03-17 14:07:16 -0400
committerRoland Dreier <roland@purestorage.com>2014-03-17 19:16:51 -0400
commit06064a103f6bd5b409ffed6248983270c0681c21 (patch)
tree868ba04bb37c3255eae4e1654a1b20b9e1f5a662 /drivers/infiniband
parent8572de9732b6d1fd211873ffab8c60b3c1745ee8 (diff)
IB/qib: Fix memory leak of recv context when driver fails to initialize.
In qib_create_ctxts() we allocate an array to hold recv contexts. Then attempt to create data for those recv contexts. If that call to qib_create_ctxtdata() fails then an error is returned but the previously allocated memory is not freed. Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/qib/qib_init.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c
index 7fbf466704ab..5b7aeb224a30 100644
--- a/drivers/infiniband/hw/qib/qib_init.c
+++ b/drivers/infiniband/hw/qib/qib_init.c
@@ -130,7 +130,6 @@ void qib_set_ctxtcnt(struct qib_devdata *dd)
130int qib_create_ctxts(struct qib_devdata *dd) 130int qib_create_ctxts(struct qib_devdata *dd)
131{ 131{
132 unsigned i; 132 unsigned i;
133 int ret;
134 int local_node_id = pcibus_to_node(dd->pcidev->bus); 133 int local_node_id = pcibus_to_node(dd->pcidev->bus);
135 134
136 if (local_node_id < 0) 135 if (local_node_id < 0)
@@ -145,8 +144,7 @@ int qib_create_ctxts(struct qib_devdata *dd)
145 if (!dd->rcd) { 144 if (!dd->rcd) {
146 qib_dev_err(dd, 145 qib_dev_err(dd,
147 "Unable to allocate ctxtdata array, failing\n"); 146 "Unable to allocate ctxtdata array, failing\n");
148 ret = -ENOMEM; 147 return -ENOMEM;
149 goto done;
150 } 148 }
151 149
152 /* create (one or more) kctxt */ 150 /* create (one or more) kctxt */
@@ -163,15 +161,14 @@ int qib_create_ctxts(struct qib_devdata *dd)
163 if (!rcd) { 161 if (!rcd) {
164 qib_dev_err(dd, 162 qib_dev_err(dd,
165 "Unable to allocate ctxtdata for Kernel ctxt, failing\n"); 163 "Unable to allocate ctxtdata for Kernel ctxt, failing\n");
166 ret = -ENOMEM; 164 kfree(dd->rcd);
167 goto done; 165 dd->rcd = NULL;
166 return -ENOMEM;
168 } 167 }
169 rcd->pkeys[0] = QIB_DEFAULT_P_KEY; 168 rcd->pkeys[0] = QIB_DEFAULT_P_KEY;
170 rcd->seq_cnt = 1; 169 rcd->seq_cnt = 1;
171 } 170 }
172 ret = 0; 171 return 0;
173done:
174 return ret;
175} 172}
176 173
177/* 174/*