When the module loads with a ne_cpus= parameter, the setter builds the CPU pool and offlines its CPUs before ne_init() runs. A pci_register_driver() failure then unloads the module with the pool still allocated and its CPUs offline, and only onlining them by hand brings them back. Tear down the pool when the driver cannot register. Fixes: ff8a4d3e3a99 ("nitro_enclaves: Add logic for setting an enclave vCPU") Signed-off-by: Alexander Graf --- drivers/virt/nitro_enclaves/ne_misc_dev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c b/drivers/virt/nitro_enclaves/ne_misc_dev.c index 308597166b819..f5d723cebb348 100644 --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c @@ -1986,7 +1986,13 @@ static long ne_ioctl(struct file *file, unsigned int cmd, unsigned long arg) static int __init ne_init(void) { - return pci_register_driver(&ne_pci_driver); + int rc; + + rc = pci_register_driver(&ne_pci_driver); + if (rc < 0) + ne_teardown_cpu_pool(); + + return rc; } static void __exit ne_exit(void) -- 2.47.1