diff options
Diffstat (limited to 'drivers/infiniband/ulp')
-rw-r--r-- | drivers/infiniband/ulp/iser/iser_verbs.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index 714b8db02b29..993f0a8ff28f 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c | |||
@@ -237,36 +237,32 @@ static int iser_free_ib_conn_res(struct iser_conn *ib_conn) | |||
237 | static | 237 | static |
238 | struct iser_device *iser_device_find_by_ib_device(struct rdma_cm_id *cma_id) | 238 | struct iser_device *iser_device_find_by_ib_device(struct rdma_cm_id *cma_id) |
239 | { | 239 | { |
240 | struct list_head *p_list; | 240 | struct iser_device *device; |
241 | struct iser_device *device = NULL; | ||
242 | 241 | ||
243 | mutex_lock(&ig.device_list_mutex); | 242 | mutex_lock(&ig.device_list_mutex); |
244 | 243 | ||
245 | p_list = ig.device_list.next; | 244 | list_for_each_entry(device, &ig.device_list, ig_list) |
246 | while (p_list != &ig.device_list) { | ||
247 | device = list_entry(p_list, struct iser_device, ig_list); | ||
248 | /* find if there's a match using the node GUID */ | 245 | /* find if there's a match using the node GUID */ |
249 | if (device->ib_device->node_guid == cma_id->device->node_guid) | 246 | if (device->ib_device->node_guid == cma_id->device->node_guid) |
250 | break; | 247 | goto inc_refcnt; |
251 | } | ||
252 | 248 | ||
253 | if (device == NULL) { | 249 | device = kzalloc(sizeof *device, GFP_KERNEL); |
254 | device = kzalloc(sizeof *device, GFP_KERNEL); | 250 | if (device == NULL) |
255 | if (device == NULL) | 251 | goto out; |
256 | goto out; | 252 | |
257 | /* assign this device to the device */ | 253 | /* assign this device to the device */ |
258 | device->ib_device = cma_id->device; | 254 | device->ib_device = cma_id->device; |
259 | /* init the device and link it into ig device list */ | 255 | /* init the device and link it into ig device list */ |
260 | if (iser_create_device_ib_res(device)) { | 256 | if (iser_create_device_ib_res(device)) { |
261 | kfree(device); | 257 | kfree(device); |
262 | device = NULL; | 258 | device = NULL; |
263 | goto out; | 259 | goto out; |
264 | } | ||
265 | list_add(&device->ig_list, &ig.device_list); | ||
266 | } | 260 | } |
267 | out: | 261 | list_add(&device->ig_list, &ig.device_list); |
268 | BUG_ON(device == NULL); | 262 | |
263 | inc_refcnt: | ||
269 | device->refcount++; | 264 | device->refcount++; |
265 | out: | ||
270 | mutex_unlock(&ig.device_list_mutex); | 266 | mutex_unlock(&ig.device_list_mutex); |
271 | return device; | 267 | return device; |
272 | } | 268 | } |
@@ -372,6 +368,12 @@ static void iser_addr_handler(struct rdma_cm_id *cma_id) | |||
372 | int ret; | 368 | int ret; |
373 | 369 | ||
374 | 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 | |||
375 | ib_conn = (struct iser_conn *)cma_id->context; | 377 | ib_conn = (struct iser_conn *)cma_id->context; |
376 | ib_conn->device = device; | 378 | ib_conn->device = device; |
377 | 379 | ||
@@ -380,7 +382,6 @@ static void iser_addr_handler(struct rdma_cm_id *cma_id) | |||
380 | iser_err("resolve route failed: %d\n", ret); | 382 | iser_err("resolve route failed: %d\n", ret); |
381 | iser_connect_error(cma_id); | 383 | iser_connect_error(cma_id); |
382 | } | 384 | } |
383 | return; | ||
384 | } | 385 | } |
385 | 386 | ||
386 | static void iser_route_handler(struct rdma_cm_id *cma_id) | 387 | static void iser_route_handler(struct rdma_cm_id *cma_id) |