diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 65b88255f..ff4c8e784 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -3508,7 +3508,7 @@ static void srpt_add_one(struct ib_device *device) sdev = kzalloc(sizeof *sdev, GFP_KERNEL); if (!sdev) - return; + goto err; sdev->scst_tgt = scst_register_target(&srpt_template, NULL); if (!sdev->scst_tgt) { @@ -3610,8 +3610,6 @@ static void srpt_add_one(struct ib_device *device) for (i = 0; i < sdev->srq_size; ++i) srpt_post_recv(sdev, sdev->ioctx_ring[i]); - ib_set_client_data(device, &srpt_client, sdev); - WARN_ON(sdev->device->phys_port_cnt > sizeof(sdev->port)/sizeof(sdev->port[0])); @@ -3636,13 +3634,14 @@ static void srpt_add_one(struct ib_device *device) } atomic_inc(&srpt_device_count); +out: + ib_set_client_data(device, &srpt_client, sdev); TRACE_EXIT(); return; err_ring: - ib_set_client_data(device, &srpt_client, NULL); srpt_free_ioctx_ring((struct srpt_ioctx **)sdev->ioctx_ring, sdev, sdev->srq_size, srp_max_req_size, DMA_FROM_DEVICE); @@ -3666,8 +3665,10 @@ unregister_tgt: scst_unregister_target(sdev->scst_tgt); free_dev: kfree(sdev); - - TRACE_EXIT(); +err: + sdev = NULL; + PRINT_INFO("%s(%s) failed.", __func__, device->name); + goto out; } /** @@ -3681,14 +3682,10 @@ static void srpt_remove_one(struct ib_device *device) TRACE_ENTRY(); sdev = ib_get_client_data(device, &srpt_client); -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18) - WARN_ON(!sdev); - if (!sdev) + if (!sdev) { + PRINT_INFO("%s(%s): nothing to do.", __func__, device->name); return; -#else - if (WARN_ON(!sdev)) - return; -#endif + } srpt_unregister_mad_agent(sdev);