diff options
author | Arne Redlich <arne.redlich@xiranet.com> | 2008-03-04 07:11:54 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2008-03-11 00:17:51 -0400 |
commit | d33ed425c6cc14370d8c418b504328d2c3db58b4 (patch) | |
tree | a026c1189014d6dc8a972c7584a6150e84679f8e /drivers/infiniband | |
parent | 9a378270c085080b2f38dee6308de4d8413b5141 (diff) |
IB/iser: Handle iser_device allocation error gracefully
"iser_device" allocation failure is "handled" with a BUG_ON() right
before dereferencing the NULL-pointer - fix this!
Signed-off-by: Arne Redlich <arne.redlich@xiranet.com>
Signed-off-by: Erez Zilber <erezz@voltaire.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/ulp/iser/iser_verbs.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index 768ba69f2fd9..993f0a8ff28f 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c | |||
@@ -244,7 +244,7 @@ struct iser_device *iser_device_find_by_ib_device(struct rdma_cm_id *cma_id) | |||
244 | list_for_each_entry(device, &ig.device_list, ig_list) | 244 | list_for_each_entry(device, &ig.device_list, ig_list) |
245 | /* find if there's a match using the node GUID */ | 245 | /* find if there's a match using the node GUID */ |
246 | if (device->ib_device->node_guid == cma_id->device->node_guid) | 246 | if (device->ib_device->node_guid == cma_id->device->node_guid) |
247 | goto out; | 247 | goto inc_refcnt; |
248 | 248 | ||
249 | device = kzalloc(sizeof *device, GFP_KERNEL); | 249 | device = kzalloc(sizeof *device, GFP_KERNEL); |
250 | if (device == NULL) | 250 | if (device == NULL) |
@@ -260,9 +260,9 @@ struct iser_device *iser_device_find_by_ib_device(struct rdma_cm_id *cma_id) | |||
260 | } | 260 | } |
261 | list_add(&device->ig_list, &ig.device_list); | 261 | list_add(&device->ig_list, &ig.device_list); |
262 | 262 | ||
263 | out: | 263 | inc_refcnt: |
264 | BUG_ON(device == NULL); | ||
265 | device->refcount++; | 264 | device->refcount++; |
265 | out: | ||
266 | mutex_unlock(&ig.device_list_mutex); | 266 | mutex_unlock(&ig.device_list_mutex); |
267 | return device; | 267 | return device; |
268 | } | 268 | } |
@@ -368,6 +368,12 @@ static void iser_addr_handler(struct rdma_cm_id *cma_id) | |||
368 | int ret; | 368 | int ret; |
369 | 369 | ||
370 | device = iser_device_find_by_ib_device(cma_id); | 370 | device = iser_device_find_by_ib_device(cma_id); |
371 | if (!device) { | ||
372 | iser_err("device lookup/creation failed\n"); | ||
373 | iser_connect_error(cma_id); | ||
374 | return; | ||
375 | } | ||
376 | |||
371 | ib_conn = (struct iser_conn *)cma_id->context; | 377 | ib_conn = (struct iser_conn *)cma_id->context; |
372 | ib_conn->device = device; | 378 | ib_conn->device = device; |
373 | 379 | ||
@@ -376,7 +382,6 @@ static void iser_addr_handler(struct rdma_cm_id *cma_id) | |||
376 | iser_err("resolve route failed: %d\n", ret); | 382 | iser_err("resolve route failed: %d\n", ret); |
377 | iser_connect_error(cma_id); | 383 | iser_connect_error(cma_id); |
378 | } | 384 | } |
379 | return; | ||
380 | } | 385 | } |
381 | 386 | ||
382 | static void iser_route_handler(struct rdma_cm_id *cma_id) | 387 | static void iser_route_handler(struct rdma_cm_id *cma_id) |