struct ib_device *dev = container_of(device, struct ib_device, dev);
WARN_ON(dev->reg_state == IB_DEV_REGISTERED);
- if (dev->reg_state == IB_DEV_UNREGISTERED) {
- /*
- * In IB_DEV_UNINITIALIZED state, cache or port table
- * is not even created. Free cache and port table only when
- * device reaches UNREGISTERED state.
- */
- ib_cache_release_one(dev);
- kfree(dev->port_immutable);
- }
+ ib_cache_release_one(dev);
ib_security_release_port_pkey_list(dev);
kfree(dev->port_pkey_list);
+ kfree(dev->port_immutable);
kfree(dev);
}
}
}
-static void cleanup_device(struct ib_device *device)
-{
- ib_cache_cleanup_one(device);
- ib_cache_release_one(device);
- kfree(device->port_immutable);
-}
-
static int setup_device(struct ib_device *device)
{
struct ib_udata uhw = {.outlen = 0, .inlen = 0};
if (ret) {
dev_warn(&device->dev,
"Couldn't query the device attributes\n");
- goto port_cleanup;
+ return ret;
}
ret = setup_port_pkey_list(device);
if (ret) {
dev_warn(&device->dev, "Couldn't create per port_pkey_list\n");
- goto port_cleanup;
- }
-
- ret = ib_cache_setup_one(device);
- if (ret) {
- dev_warn(&device->dev,
- "Couldn't set up InfiniBand P_Key/GID cache\n");
return ret;
}
- return 0;
-port_cleanup:
- kfree(device->port_immutable);
- return ret;
+ return 0;
}
/**
if (ret)
goto out;
+ ret = ib_cache_setup_one(device);
+ if (ret) {
+ dev_warn(&device->dev,
+ "Couldn't set up InfiniBand P_Key/GID cache\n");
+ goto out;
+ }
+
device->index = __dev_new_index();
ib_device_register_rdmacg(device);
cg_cleanup:
ib_device_unregister_rdmacg(device);
- cleanup_device(device);
+ ib_cache_cleanup_one(device);
out:
mutex_unlock(&device_mutex);
return ret;