diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 5e70f5e1cfd98..d175b94ae9527 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -545,14 +545,14 @@ int ib_register_device(struct ib_device *device, const char *name, ret = setup_port_pkey_list(device); if (ret) { dev_warn(&device->dev, "Couldn't create per port_pkey_list\n"); - goto out; + 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"); - goto port_cleanup; + goto pkey_cleanup; } device->index = __dev_new_index(); @@ -596,6 +596,8 @@ int ib_register_device(struct ib_device *device, const char *name, cache_cleanup: ib_cache_cleanup_one(device); ib_cache_release_one(device); +pkey_cleanup: + kfree(device->port_pkey_list); port_cleanup: kfree(device->port_immutable); out: