Commit 0b4a17fc634bf511bfca67ab4c6ecea5ad6db058

Authored by David Hildenbrand
Committed by Greg Kroah-Hartman
1 parent 6d6cdcaf12

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
... ... @@ -876,6 +876,7 @@
876 876 struct kvm_s390_interrupt *s390int)
877 877 {
878 878 struct kvm_s390_interrupt_info *inti;
  879 + int rc;
879 880  
880 881 inti = kzalloc(sizeof(*inti), GFP_KERNEL);
881 882 if (!inti)
... ... @@ -923,7 +924,10 @@
923 924 trace_kvm_s390_inject_vm(s390int->type, s390int->parm, s390int->parm64,
924 925 2);
925 926  
926   - return __inject_vm(kvm, inti);
  927 + rc = __inject_vm(kvm, inti);
  928 + if (rc)
  929 + kfree(inti);
  930 + return rc;
927 931 }
928 932  
929 933 void kvm_s390_reinject_io_int(struct kvm *kvm,