Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752869Ab0ATPTG (ORCPT ); Wed, 20 Jan 2010 10:19:06 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752461Ab0ATPTB (ORCPT ); Wed, 20 Jan 2010 10:19:01 -0500 Received: from gimli.pxnet.com ([195.227.45.7]:36906 "EHLO mail.pxnet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752300Ab0ATPTA (ORCPT ); Wed, 20 Jan 2010 10:19:00 -0500 From: Tilman Schmidt Subject: Re: Can we remove pci_find_device() yet? To: Alan Cox Cc: Andi Kleen , Greg KH , Stephen Rothwell , LKML , netdev@vger.kernel.org, Karsten Keil , isdn4linux@listserv.isdn4linux.de References: <20100108112236.462a3da2.sfr@canb.auug.org.au> <20100108044646.GC6611@suse.de> <4B4B802A.2010709@imap.cc> <20100111200136.GA29955@suse.de> <877hrlf0rf.fsf@basil.nowhere.org> <20100114110214.37d7ffc9@lxorguk.ukuu.org.uk> Message-Id: <20100120151109.29FA240109@xenon.ts.pxnet.com> Date: Wed, 20 Jan 2010 16:11:08 +0100 (CET) X-Spam-Score: -2.185 () AWL,BAYES_00,RDNS_NONE Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2445 Lines: 63 On Thu, Jan 14, 2010 at 11:02:14AM +0000, Alan Cox wrote: > > e.g. set some global variable that forbids device removal > > and warn in the kernel log. In theory this could be also > > done per device, but I guess that would be more effort. > > There is a simpler way to do that, which is to just leak a reference in > the hisax_find_pci_device hack. The pci_dev won't be going anywhere then. Something like this? (On top of my previous patch introducing hisax_find_pci_device in the first place.) Subject: [PATCH RFC] isdn/hisax: intentionally leak a reference in hisax_find_pci_device Take a reference to the returned pci_dev which will never be released. Until the HiSax drivers are fixed for proper PCI hotplug support, this appears as the lesser evil compared to the danger of the structure being freed without the caller knowing it. Impact: replacing a bug by another, less consequential one Signed-off-by: Tilman Schmidt --- drivers/isdn/hisax/hisax.h | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h index 832a878..e459502 100644 --- a/drivers/isdn/hisax/hisax.h +++ b/drivers/isdn/hisax/hisax.h @@ -1328,21 +1328,18 @@ void TeiFree(void); #include -/* adaptation wrapper for old usage - * WARNING! This is unfit for use in a PCI hotplug environment, - * as the returned PCI device can disappear at any moment in time. +/* This function replaces the former function pci_find_device(). + * Unlike the latter, it takes a reference on the returned pci_dev, + * resulting in a reference leak. This is intentional and serves to + * prevent an untimely release of the PCI device structure. * Callers should be converted to use pci_get_device() instead. */ static inline struct pci_dev *hisax_find_pci_device(unsigned int vendor, unsigned int device, struct pci_dev *from) { - struct pci_dev *pdev; - pci_dev_get(from); - pdev = pci_get_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from); - pci_dev_put(pdev); - return pdev; + return pci_get_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from); } #endif -- 1.6.5.3.298.g39add -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/