The ne_cpus setter can run before ne_init(), when the parameter is given at boot or to modprobe, and then takes ne_cpu_pool.mutex before mutex_init() ran on it. Initialise the mutex in its definition instead. Fixes: ff8a4d3e3a99 ("nitro_enclaves: Add logic for setting an enclave vCPU") Signed-off-by: Alexander Graf --- drivers/virt/nitro_enclaves/ne_misc_dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c b/drivers/virt/nitro_enclaves/ne_misc_dev.c index f4a531e705917..308597166b819 100644 --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c @@ -125,7 +125,9 @@ struct ne_cpu_pool { int numa_node; }; -static struct ne_cpu_pool ne_cpu_pool; +static struct ne_cpu_pool ne_cpu_pool = { + .mutex = __MUTEX_INITIALIZER(ne_cpu_pool.mutex), +}; /** * struct ne_phys_contig_mem_regions - Contiguous physical memory regions. @@ -1984,8 +1986,6 @@ static long ne_ioctl(struct file *file, unsigned int cmd, unsigned long arg) static int __init ne_init(void) { - mutex_init(&ne_cpu_pool.mutex); - return pci_register_driver(&ne_pci_driver); } -- 2.47.1