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>
This commit is contained in:
Arne Redlich 2008-03-04 14:11:54 +02:00 committed by Roland Dreier
parent 9a378270c0
commit d33ed425c6

View File

@ -244,7 +244,7 @@ struct iser_device *iser_device_find_by_ib_device(struct rdma_cm_id *cma_id)
list_for_each_entry(device, &ig.device_list, ig_list) list_for_each_entry(device, &ig.device_list, ig_list)
/* find if there's a match using the node GUID */ /* find if there's a match using the node GUID */
if (device->ib_device->node_guid == cma_id->device->node_guid) if (device->ib_device->node_guid == cma_id->device->node_guid)
goto out; goto inc_refcnt;
device = kzalloc(sizeof *device, GFP_KERNEL); device = kzalloc(sizeof *device, GFP_KERNEL);
if (device == NULL) if (device == NULL)
@ -260,9 +260,9 @@ struct iser_device *iser_device_find_by_ib_device(struct rdma_cm_id *cma_id)
} }
list_add(&device->ig_list, &ig.device_list); list_add(&device->ig_list, &ig.device_list);
out: inc_refcnt:
BUG_ON(device == NULL);
device->refcount++; device->refcount++;
out:
mutex_unlock(&ig.device_list_mutex); mutex_unlock(&ig.device_list_mutex);
return device; return device;
} }
@ -368,6 +368,12 @@ static void iser_addr_handler(struct rdma_cm_id *cma_id)
int ret; int ret;
device = iser_device_find_by_ib_device(cma_id); device = iser_device_find_by_ib_device(cma_id);
if (!device) {
iser_err("device lookup/creation failed\n");
iser_connect_error(cma_id);
return;
}
ib_conn = (struct iser_conn *)cma_id->context; ib_conn = (struct iser_conn *)cma_id->context;
ib_conn->device = device; ib_conn->device = device;
@ -376,7 +382,6 @@ static void iser_addr_handler(struct rdma_cm_id *cma_id)
iser_err("resolve route failed: %d\n", ret); iser_err("resolve route failed: %d\n", ret);
iser_connect_error(cma_id); iser_connect_error(cma_id);
} }
return;
} }
static void iser_route_handler(struct rdma_cm_id *cma_id) static void iser_route_handler(struct rdma_cm_id *cma_id)