+ /* This is safe, since we have a reference from open(). */This isn't sufficient. For x86, it only grabs a reference to kvm.ko, not the
+ __module_get(THIS_MODULE);
vendor module. Instead, we can do:
if (!try_module_get(kvm_chardev_ops.owner))
return ERR_PTR(-EINVAL);
And then on top, revert commit revert ("KVM: set owner of cpu and vm file operations").
vCPUs file descriptors hold reference to the VM, which means they indirectly hold a
reference to the module. So once the "real" bug of struct kvm not holding a reference
to the module is fixed, grabbing a reference when a VM/vCPU inode is opened becomes
unnecessary.