From mboxrd@z Thu Jan 1 00:00:00 1970 From: Josh Triplett Subject: [PATCH kvmtool] kvm__emulate_io: Don't call br_read_unlock() twice on IO error Date: Thu, 6 Aug 2015 11:39:44 -0700 Message-ID: <20150806183944.GA6720@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]:60323 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754811AbbHFSjs (ORCPT ); Thu, 6 Aug 2015 14:39:48 -0400 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: The IO error path in kvm__emulate_io would call br_read_unlock(), then goto error, which would call br_read_unlock() again. Refactor the control flow to have only one exit path and one call to br_read_unlock(). Signed-off-by: Josh Triplett --- ioport.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ioport.c b/ioport.c index 81a747d..8c55a84 100644 --- a/ioport.c +++ b/ioport.c @@ -185,7 +185,7 @@ bool kvm__emulate_io(struct kvm_cpu *vcpu, u16 port, void *data, int direction, br_read_lock(); entry = ioport_search(&ioport_tree, port); if (!entry) - goto error; + goto out; ops = entry->ops; @@ -198,14 +198,11 @@ bool kvm__emulate_io(struct kvm_cpu *vcpu, u16 port, void *data, int direction, ptr += size; } +out: br_read_unlock(); - if (!ret) - goto error; - - return true; -error: - br_read_unlock(); + if (ret) + return true; if (kvm->cfg.ioport_debug) ioport_error(port, data, direction, size, count); -- 2.5.0