kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH kvmtool] kvm__emulate_io: Don't call br_read_unlock() twice on IO error
@ 2015-08-06 18:39 Josh Triplett
  2015-08-07 14:37 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Josh Triplett @ 2015-08-06 18:39 UTC (permalink / raw)
  To: kvm; +Cc: Will Deacon

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-07 14:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-06 18:39 [PATCH kvmtool] kvm__emulate_io: Don't call br_read_unlock() twice on IO error Josh Triplett
2015-08-07 14:37 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).