Commit 57a1612afaa6f7400e4b73de7efe93282d0d2261

Authored by David Hildenbrand
Committed by Greg Kroah-Hartman
1 parent a9496df45f

KVM: s390: avoid memory leaks if __inject_vm() fails

commit 428d53be5e7468769d4e7899cca06ed5f783a6e1 upstream.

We have to delete the allocated interrupt info if __inject_vm() fails.

Otherwise user space can keep flooding kvm with floating interrupts and
provoke more and more memory leaks.

Reported-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
Reviewed-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 5 additions and 1 deletions Side-by-side Diff

arch/s390/kvm/interrupt.c
... ... @@ -1233,6 +1233,7 @@
1233 1233 struct kvm_s390_interrupt *s390int)
1234 1234 {
1235 1235 struct kvm_s390_interrupt_info *inti;
  1236 + int rc;
1236 1237  
1237 1238 inti = kzalloc(sizeof(*inti), GFP_KERNEL);
1238 1239 if (!inti)
... ... @@ -1280,7 +1281,10 @@
1280 1281 trace_kvm_s390_inject_vm(s390int->type, s390int->parm, s390int->parm64,
1281 1282 2);
1282 1283  
1283   - return __inject_vm(kvm, inti);
  1284 + rc = __inject_vm(kvm, inti);
  1285 + if (rc)
  1286 + kfree(inti);
  1287 + return rc;
1284 1288 }
1285 1289  
1286 1290 void kvm_s390_reinject_io_int(struct kvm *kvm,