From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EE64A2C00A9 for ; Thu, 16 May 2013 07:32:53 +1000 (EST) Message-ID: <1368653557.9603.21.camel@pasglop> Subject: Re: [PATCH v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead From: Benjamin Herrenschmidt To: Yinghai Lu Date: Thu, 16 May 2013 07:32:37 +1000 In-Reply-To: References: <1368461313-4371-1-git-send-email-jiang.liu@huawei.com> <1368461313-4371-4-git-send-email-jiang.liu@huawei.com> <5191F53E.4000305@cn.fujitsu.com> <51925136.5050302@gmail.com> <51926CF6.1050706@gmail.com> <51939E16.9090105@gmail.com> <51939FB1.20203@gmail.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Cc: Bjorn Helgaas , Myron Stowe , Greg Kroah-Hartman , Linux Kernel Mailing List , "Rafael J . Wysocki" , Gu Zheng , Paul Mackerras , "linux-pci@vger.kernel.org" , "sparclinux@vger.kernel.org" , linuxppc-dev@lists.ozlabs.org, "David S. Miller" , Liu Jiang List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Wed, 2013-05-15 at 07:58 -0700, Yinghai Lu wrote: > Ben, > > in drivers/pci/probe.c::pci_scan_device() there is > > pci_set_of_node(dev); > > if (pci_setup_device(dev)) { > kfree(dev); > return NULL; > } > > so if pci_setup_device fails, there is one dev reference is not release. > > please check you can just move down pci_set_of_node down after that > failing path, like > > > if (pci_setup_device(dev)) { > kfree(dev); > return NULL; > } > > pci_set_of_node(dev); No, we want the OF node set when we run the quirks, we intentionally do that early, the right thing to do is to to call pci_release_of_node() in the error path (it's safe to call even if the node is NULL). Cheers, Ben.