From patchwork Wed Mar 23 07:26:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Jiangang X-Patchwork-Id: 8647361 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 53134C0553 for ; Wed, 23 Mar 2016 07:27:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7007201F2 for ; Wed, 23 Mar 2016 07:27:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B94C2015E for ; Wed, 23 Mar 2016 07:27:35 +0000 (UTC) Received: from localhost ([::1]:41579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aidCY-0004oH-Cl for patchwork-qemu-devel@patchwork.kernel.org; Wed, 23 Mar 2016 03:27:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aidCM-0004kk-Fi for qemu-devel@nongnu.org; Wed, 23 Mar 2016 03:27:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aidCI-0003yl-FU for qemu-devel@nongnu.org; Wed, 23 Mar 2016 03:27:22 -0400 Received: from [59.151.112.132] (port=6558 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aidCI-0003ye-1d for qemu-devel@nongnu.org; Wed, 23 Mar 2016 03:27:18 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="4880948" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 23 Mar 2016 15:27:15 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 75FB9408D262; Wed, 23 Mar 2016 15:27:10 +0800 (CST) Received: from localhost.localdomain (10.167.226.50) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.279.2; Wed, 23 Mar 2016 15:27:10 +0800 From: Wei Jiangang To: Date: Wed, 23 Mar 2016 15:26:19 +0800 Message-ID: <1458717980-26686-2-git-send-email-weijg.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1458717980-26686-1-git-send-email-weijg.fnst@cn.fujitsu.com> References: <1458717980-26686-1-git-send-email-weijg.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.50] X-yoursite-MailScanner-ID: 75FB9408D262.AC6F5 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: weijg.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: marcel@redhat.com, Cao jin , Wei Jiangang , armbru@redhat.com Subject: [Qemu-devel] [PATCH v2 1/2] hw/pci-bridge: Add missing unref in case register-bus fails 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable 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 error paths after a successful qdev_create/pci_bus_new should contain a object_unref/object_unparent. pxb_dev_init_common() did not yet, so add it. Signed-off-by: Wei Jiangang Signed-off-by: Cao jin Reviewed-by: Marcel Apfelbaum --- hw/pci-bridge/pci_expander_bridge.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c index 5e7e546..ba320bd 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -249,7 +249,7 @@ static int pxb_dev_init_common(PCIDevice *dev, bool pcie) PCI_HOST_BRIDGE(ds)->bus = bus; if (pxb_register_bus(dev, bus)) { - return -EINVAL; + goto err_register_bus; } qdev_init_nofail(ds); @@ -263,6 +263,12 @@ static int pxb_dev_init_common(PCIDevice *dev, bool pcie) pxb_dev_list = g_list_insert_sorted(pxb_dev_list, pxb, pxb_compare); return 0; + +err_register_bus: + object_unref(OBJECT(bds)); + object_unparent(OBJECT(bus)); + object_unref(OBJECT(ds)); + return -EINVAL; } static int pxb_dev_initfn(PCIDevice *dev)