From patchwork Thu Aug 6 18:39:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Triplett X-Patchwork-Id: 6962011 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7CFED9F39D for ; Thu, 6 Aug 2015 18:39:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A28CF206F5 for ; Thu, 6 Aug 2015 18:39:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 735F0206EF for ; Thu, 6 Aug 2015 18:39:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755749AbbHFSjs (ORCPT ); Thu, 6 Aug 2015 14:39:48 -0400 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 Received: from cloud (joshtriplett.org [IPv6:2604:3400:dc1:41:216:3eff:fe9f:2070]) (Authenticated sender: josh@joshtriplett.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 0F22CA80AF; Thu, 6 Aug 2015 20:39:45 +0200 (CEST) Date: Thu, 6 Aug 2015 11:39:44 -0700 From: Josh Triplett To: kvm@vger.kernel.org Cc: Will Deacon Subject: [PATCH kvmtool] kvm__emulate_io: Don't call br_read_unlock() twice on IO error Message-ID: <20150806183944.GA6720@cloud> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);