cuse: fix nvme_cuse unregister segfault
Unregistering nvme_cuse when the device did not exist
resulted in SEGFAULT within nvme_io_msg_ctrlr_unregister().
To prevent that, when no nvme_cuse is registered for the
ctrlr do not unregister nvme_io_msg_producer.
RPC and spdk_nvme_cuse_unregister() now return an error.
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1921 (master)
For backporting to 20.01.x, API breaking changes were removed.
Only part that could cause the segfault remained.
(cherry picked from commit d9a11fd5b1
)
Change-Id: Id77cebe23ff91023a24cfe091f5f62a76a9175fd
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2156
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
d42b332ae6
commit
cbb1d099ff
@ -951,7 +951,15 @@ spdk_nvme_cuse_register(struct spdk_nvme_ctrlr *ctrlr)
|
||||
void
|
||||
spdk_nvme_cuse_unregister(struct spdk_nvme_ctrlr *ctrlr)
|
||||
{
|
||||
nvme_cuse_stop(ctrlr);
|
||||
struct cuse_device *ctrlr_device;
|
||||
|
||||
ctrlr_device = nvme_cuse_get_cuse_ctrlr_device(ctrlr);
|
||||
if (!ctrlr_device) {
|
||||
SPDK_ERRLOG("Cannot find associated CUSE device\n");
|
||||
return;
|
||||
}
|
||||
|
||||
cuse_nvme_ctrlr_stop(ctrlr_device);
|
||||
|
||||
nvme_io_msg_ctrlr_unregister(ctrlr, &cuse_nvme_io_msg_producer);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user