From patchwork Thu May 3 02:42:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Baron X-Patchwork-Id: 156598 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BA710B6FAB for ; Thu, 3 May 2012 12:42:48 +1000 (EST) Received: from localhost ([::1]:39434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPm0E-0007Xu-Gh for incoming@patchwork.ozlabs.org; Wed, 02 May 2012 22:42:46 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPlzn-0006LV-Ax for qemu-devel@nongnu.org; Wed, 02 May 2012 22:42:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPlzl-0004Ep-IU for qemu-devel@nongnu.org; Wed, 02 May 2012 22:42:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8742) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPlzl-0004Ed-AW for qemu-devel@nongnu.org; Wed, 02 May 2012 22:42:17 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q432gFde028309 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 2 May 2012 22:42:15 -0400 Received: from redhat.com (vpn-10-160.rdu.redhat.com [10.11.10.160]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q432gFnT024595; Wed, 2 May 2012 22:42:15 -0400 Date: Wed, 2 May 2012 22:42:15 -0400 From: Jason Baron To: qemu-devel@nongnu.org Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, alex.williamson@redhat.com, aliguori@us.ibm.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 2/2] pci_bridge_dev: fix error path in pci_bridge_dev_initfn() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Currently, we do not properly cleanup, if pci_bridge_dev_initfn fails to initialize properly. Make sure to call pci_bridge_exitfn() in the error path. Signed-off-by: Jason Baron --- hw/pci_bridge_dev.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/hw/pci_bridge_dev.c b/hw/pci_bridge_dev.c index eccaa58..ad63703 100644 --- a/hw/pci_bridge_dev.c +++ b/hw/pci_bridge_dev.c @@ -52,7 +52,7 @@ static int pci_bridge_dev_initfn(PCIDevice *dev) { PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev); PCIBridgeDev *bridge_dev = DO_UPCAST(PCIBridgeDev, bridge, br); - int err; + int err, ret; pci_bridge_map_irq(br, NULL, pci_bridge_dev_map_irq_fn); err = pci_bridge_initfn(dev); if (err) { @@ -86,6 +86,8 @@ slotid_error: shpc_cleanup(dev, &bridge_dev->bar); shpc_error: memory_region_destroy(&bridge_dev->bar); + ret = pci_bridge_exitfn(dev); + assert(!ret); bridge_error: return err; }