From patchwork Tue May 14 14:59:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 2566681 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 3D7C23FC5A for ; Tue, 14 May 2013 14:59:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756717Ab3ENO7N (ORCPT ); Tue, 14 May 2013 10:59:13 -0400 Received: from mail-da0-f50.google.com ([209.85.210.50]:55758 "EHLO mail-da0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752555Ab3ENO7M (ORCPT ); Tue, 14 May 2013 10:59:12 -0400 Received: by mail-da0-f50.google.com with SMTP id i23so355461dad.23 for ; Tue, 14 May 2013 07:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=Ae2fTGQ2F2tJusCg9dun12rZjDBDpLRnFlZyxZXEwiM=; b=Z1kCKTCSkCzn2isH8pav9QxTVndughSYLn/NFp35bBjp3wqwTs1QZ5lBNprylkMn8L pRI5sQ9kVfAQPjFee7nRCMUieYeVzd/BCfPghW1cD/BNzz1PGpYPZCYSpLCpVwHzuzdU Wmn27x67naIpdw9p2fDFZCxpdzGCsX1fXYzDK0nb6RPPWjAfeFQDUxdADCQcUNfiW9l1 0oLf8Lepuc9FvddsaTxIi2rJT9KOSH5VVKYK7pN2h4dQqDgpqXVF6buMiaGs5WBisV12 KXANGjMs/27dWGI9J+r3dDY76oAJvRZuvcCZPXlbOAncTQOKOjgKoaguZTckXWmEbkLi Gp9g== X-Received: by 10.66.51.102 with SMTP id j6mr34097748pao.210.1368543551063; Tue, 14 May 2013 07:59:11 -0700 (PDT) Received: from [172.21.37.250] ([120.196.98.100]) by mx.google.com with ESMTPSA id at1sm17315404pbc.10.2013.05.14.07.59.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 May 2013 07:59:10 -0700 (PDT) Message-ID: <51925136.5050302@gmail.com> Date: Tue, 14 May 2013 22:59:02 +0800 From: Liu Jiang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130404 Thunderbird/17.0.5 MIME-Version: 1.0 To: Gu Zheng CC: Yinghai Lu , Bjorn Helgaas , "Rafael J . Wysocki" , Greg Kroah-Hartman , Toshi Kani , Myron Stowe , Yijing Wang , "linux-pci@vger.kernel.org" , Linux Kernel Mailing List , Benjamin Herrenschmidt , Paul Mackerras , "David S. Miller" , David Airlie , Neela Syam Kolli , "James E.J. Bottomley" , Andrew Morton , linuxppc-dev@lists.ozlabs.org, "sparclinux@vger.kernel.org" , Linux-Scsi , Jiang Liu Subject: Re: [PATCH v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead 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> In-Reply-To: <5191F53E.4000305@cn.fujitsu.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On 05/14/2013 04:26 PM, Gu Zheng wrote: > On 05/14/2013 01:23 AM, Yinghai Lu wrote: > >> On Mon, May 13, 2013 at 9:08 AM, Jiang Liu wrote: >>> From: Gu Zheng >>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c >>> index 4f0bc0a..bc075a3 100644 >>> --- a/drivers/pci/probe.c >>> +++ b/drivers/pci/probe.c >>> @@ -1131,6 +1131,7 @@ static void pci_release_dev(struct device *dev) >>> struct pci_dev *pci_dev; >>> >>> pci_dev = to_pci_dev(dev); >>> + pci_bus_put(pci_dev->bus); >>> pci_release_capabilities(pci_dev); >>> pci_release_of_node(pci_dev); >>> kfree(pci_dev); >>> @@ -1269,11 +1270,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) >>> if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000)) >>> return NULL; >>> >>> - dev = alloc_pci_dev(); >>> + dev = pci_alloc_dev(bus); >>> if (!dev) >>> return NULL; >>> >>> - dev->bus = bus; >>> dev->devfn = devfn; >>> dev->vendor = l & 0xffff; >>> dev->device = (l >> 16) & 0xffff; >> in pci_setup_device() fail path, it release the ref to that bus. > Yes, you're right, we need to release the bus' ref if pci_setup_device() failed. Hi Zheng, I suggest to use pci_release_dev() instead because it also needs to release OF related resources. I will update it in next version. > hanks for your correction.:) > > Best regards, > Gu > >> Yinghai >> > --- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index bc075a3..2ac6338 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1281,7 +1281,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus pci_set_of_node(dev); if (pci_setup_device(dev)) { - kfree(dev); + pci_release_dev(&dev->dev); return NULL; }