public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Josh Triplett <josh@joshtriplett.org>
To: kvm@vger.kernel.org
Cc: Will Deacon <will.deacon@arm.com>
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	[thread overview]
Message-ID: <20150806183944.GA6720@cloud> (raw)

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 <josh@joshtriplett.org>
---
 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


             reply	other threads:[~2015-08-06 18:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-06 18:39 Josh Triplett [this message]
2015-08-07 14:37 ` [PATCH kvmtool] kvm__emulate_io: Don't call br_read_unlock() twice on IO error Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150806183944.GA6720@cloud \
    --to=josh@joshtriplett.org \
    --cc=kvm@vger.kernel.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox