Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67fecaf8 authored by Parav Pandit's avatar Parav Pandit Committed by Doug Ledford
Browse files

RDMA/core: Fix unwinding flow in case of error to register device



If port pkey list initialization fails, free the port_immutable memory
during cleanup path. Currently it is missed out.

If cache setup fails, free the pkey list during cleanup path.

Fixes: d291f1a6 ("IB/core: Enforce PKey security on QPs")
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 56e027a6
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -545,14 +545,14 @@ int ib_register_device(struct ib_device *device, const char *name,
	ret = setup_port_pkey_list(device);
	ret = setup_port_pkey_list(device);
	if (ret) {
	if (ret) {
		dev_warn(&device->dev, "Couldn't create per port_pkey_list\n");
		dev_warn(&device->dev, "Couldn't create per port_pkey_list\n");
		goto out;
		goto port_cleanup;
	}
	}


	ret = ib_cache_setup_one(device);
	ret = ib_cache_setup_one(device);
	if (ret) {
	if (ret) {
		dev_warn(&device->dev,
		dev_warn(&device->dev,
			 "Couldn't set up InfiniBand P_Key/GID cache\n");
			 "Couldn't set up InfiniBand P_Key/GID cache\n");
		goto port_cleanup;
		goto pkey_cleanup;
	}
	}


	device->index = __dev_new_index();
	device->index = __dev_new_index();
@@ -596,6 +596,8 @@ int ib_register_device(struct ib_device *device, const char *name,
cache_cleanup:
cache_cleanup:
	ib_cache_cleanup_one(device);
	ib_cache_cleanup_one(device);
	ib_cache_release_one(device);
	ib_cache_release_one(device);
pkey_cleanup:
	kfree(device->port_pkey_list);
port_cleanup:
port_cleanup:
	kfree(device->port_immutable);
	kfree(device->port_immutable);
out:
out: