In case all of the following apply at the same time: * a higher priority GISA interrupt is pending * a lower priority classic interrupt is also pending * the pending interrupt queue is full then kvm_s390_reinject_io_int() will fail, the classic interrupt is dropped and its memory is leaked. Fix by checking whether the reinjection of the interrupt succeeded, and free it if not. The interrupt is still dropped, but no leak occurs. This is not expected to happen during normal guest operation, due to the large maximum size of the pending interrupt queue. Fixes: 4b35f65e67ee ("KVM: s390: make kvm_s390_get_io_int() aware of GISA") Cc: stable@vger.kernel.org Signed-off-by: Claudio Imbrenda --- arch/s390/kvm/s390/interrupt.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/s390/kvm/s390/interrupt.c b/arch/s390/kvm/s390/interrupt.c index 31a6074feffc..33672f093322 100644 --- a/arch/s390/kvm/s390/interrupt.c +++ b/arch/s390/kvm/s390/interrupt.c @@ -1775,8 +1775,17 @@ struct kvm_s390_interrupt_info *kvm_s390_get_io_int(struct kvm *kvm, if (tmp_inti) { tmp_inti->type = KVM_S390_INT_IO(1, 0, 0, 0); tmp_inti->io.io_int_word = isc_to_int_word(isc); - if (inti) - kvm_s390_reinject_io_int(kvm, inti); + if (inti) { + /* + * The maximum number of pending interrupts is so + * high that this is impossible in practice during + * normal guest operation. + * Drop the interrupt if the limit was somehow + * reached anyway, and free it, to avoid a leak. + */ + if (kvm_s390_reinject_io_int(kvm, inti)) + kfree(inti); + } inti = tmp_inti; } else gisa_set_ipm_gisc(gi->origin, isc); -- 2.56.1