@@ -115,8 +115,6 @@ EXPORT_SYMBOL_GPL(kvm_debugfs_dir);
115
115
116
116
static const struct file_operations stat_fops_per_vm ;
117
117
118
- static struct file_operations kvm_chardev_ops ;
119
-
120
118
static long kvm_vcpu_ioctl (struct file * file , unsigned int ioctl ,
121
119
unsigned long arg );
122
120
#ifdef CONFIG_KVM_COMPAT
@@ -1157,9 +1155,6 @@ static struct kvm *kvm_create_vm(unsigned long type, const char *fdname)
1157
1155
if (!kvm )
1158
1156
return ERR_PTR (- ENOMEM );
1159
1157
1160
- /* KVM is pinned via open("/dev/kvm"), the fd passed to this ioctl(). */
1161
- __module_get (kvm_chardev_ops .owner );
1162
-
1163
1158
KVM_MMU_LOCK_INIT (kvm );
1164
1159
mmgrab (current -> mm );
1165
1160
kvm -> mm = current -> mm ;
@@ -1279,7 +1274,6 @@ static struct kvm *kvm_create_vm(unsigned long type, const char *fdname)
1279
1274
out_err_no_srcu :
1280
1275
kvm_arch_free_vm (kvm );
1281
1276
mmdrop (current -> mm );
1282
- module_put (kvm_chardev_ops .owner );
1283
1277
return ERR_PTR (r );
1284
1278
}
1285
1279
@@ -1348,7 +1342,6 @@ static void kvm_destroy_vm(struct kvm *kvm)
1348
1342
preempt_notifier_dec ();
1349
1343
hardware_disable_all ();
1350
1344
mmdrop (mm );
1351
- module_put (kvm_chardev_ops .owner );
1352
1345
}
1353
1346
1354
1347
void kvm_get_kvm (struct kvm * kvm )
@@ -3887,7 +3880,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
3887
3880
return 0 ;
3888
3881
}
3889
3882
3890
- static const struct file_operations kvm_vcpu_fops = {
3883
+ static struct file_operations kvm_vcpu_fops = {
3891
3884
.release = kvm_vcpu_release ,
3892
3885
.unlocked_ioctl = kvm_vcpu_ioctl ,
3893
3886
.mmap = kvm_vcpu_mmap ,
@@ -4081,6 +4074,7 @@ static int kvm_vcpu_stats_release(struct inode *inode, struct file *file)
4081
4074
}
4082
4075
4083
4076
static const struct file_operations kvm_vcpu_stats_fops = {
4077
+ .owner = THIS_MODULE ,
4084
4078
.read = kvm_vcpu_stats_read ,
4085
4079
.release = kvm_vcpu_stats_release ,
4086
4080
.llseek = noop_llseek ,
@@ -4431,7 +4425,7 @@ static int kvm_device_release(struct inode *inode, struct file *filp)
4431
4425
return 0 ;
4432
4426
}
4433
4427
4434
- static const struct file_operations kvm_device_fops = {
4428
+ static struct file_operations kvm_device_fops = {
4435
4429
.unlocked_ioctl = kvm_device_ioctl ,
4436
4430
.release = kvm_device_release ,
4437
4431
KVM_COMPAT (kvm_device_ioctl ),
@@ -4759,6 +4753,7 @@ static int kvm_vm_stats_release(struct inode *inode, struct file *file)
4759
4753
}
4760
4754
4761
4755
static const struct file_operations kvm_vm_stats_fops = {
4756
+ .owner = THIS_MODULE ,
4762
4757
.read = kvm_vm_stats_read ,
4763
4758
.release = kvm_vm_stats_release ,
4764
4759
.llseek = noop_llseek ,
@@ -5060,7 +5055,7 @@ static long kvm_vm_compat_ioctl(struct file *filp,
5060
5055
}
5061
5056
#endif
5062
5057
5063
- static const struct file_operations kvm_vm_fops = {
5058
+ static struct file_operations kvm_vm_fops = {
5064
5059
.release = kvm_vm_release ,
5065
5060
.unlocked_ioctl = kvm_vm_ioctl ,
5066
5061
.llseek = noop_llseek ,
@@ -6095,6 +6090,9 @@ int kvm_init(unsigned vcpu_size, unsigned vcpu_align, struct module *module)
6095
6090
goto err_async_pf ;
6096
6091
6097
6092
kvm_chardev_ops .owner = module ;
6093
+ kvm_vm_fops .owner = module ;
6094
+ kvm_vcpu_fops .owner = module ;
6095
+ kvm_device_fops .owner = module ;
6098
6096
6099
6097
kvm_preempt_ops .sched_in = kvm_sched_in ;
6100
6098
kvm_preempt_ops .sched_out = kvm_sched_out ;
0 commit comments