From mboxrd@z Thu Jan 1 00:00:00 1970 From: Josh Triplett Subject: [PATCH kvmtool] kvm__emulate_io: Don't fall through from IO in to IO out if no handler Date: Thu, 6 Aug 2015 11:39:59 -0700 Message-ID: <20150806183959.GA6740@cloud> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Will Deacon To: kvm@vger.kernel.org Return-path: Received: from relay3-d.mail.gandi.net ([217.70.183.195]:55337 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755781AbbHFSkC (ORCPT ); Thu, 6 Aug 2015 14:40:02 -0400 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: If an IO port device has no io_in handler, kvm__emulate_io would fall through and call the io_out handler instead. Fix to only call the handler for the appropriate direction. If no handler exists, kvm__emulate_io will automatically treat it as an IO error (due to the default "ret = false"). Signed-off-by: Josh Triplett --- ioport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ioport.c b/ioport.c index 8c55a84..263fe50 100644 --- a/ioport.c +++ b/ioport.c @@ -192,7 +192,7 @@ bool kvm__emulate_io(struct kvm_cpu *vcpu, u16 port, void *data, int direction, while (count--) { if (direction == KVM_EXIT_IO_IN && ops->io_in) ret = ops->io_in(entry, vcpu, port, ptr, size); - else if (ops->io_out) + else if (direction == KVM_EXIT_IO_OUT && ops->io_out) ret = ops->io_out(entry, vcpu, port, ptr, size); ptr += size; -- 2.5.0