Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S262462AbVCMAE3 (ORCPT ); Sat, 12 Mar 2005 19:04:29 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S262500AbVCMACX (ORCPT ); Sat, 12 Mar 2005 19:02:23 -0500 Received: from mail.kroah.org ([69.55.234.183]:12968 "EHLO perch.kroah.org") by vger.kernel.org with ESMTP id S262554AbVCMACL (ORCPT ); Sat, 12 Mar 2005 19:02:11 -0500 Date: Sat, 12 Mar 2005 12:49:56 -0800 From: Greg KH To: Dave Jones , Benjamin Herrenschmidt , Paul Mackerras , Linus Torvalds , Linux Kernel list Subject: Re: AGP bogosities Message-ID: <20050312204956.GD11865@kroah.com> References: <16944.62310.967444.786526@cargo.ozlabs.ibm.com> <20050311021248.GA20697@redhat.com> <16944.65532.632559.277927@cargo.ozlabs.ibm.com> <20050311022332.GB20697@redhat.com> <1110508824.32556.320.camel@gaston> <20050311024953.GE20697@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050311024953.GE20697@redhat.com> User-Agent: Mutt/1.5.8i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1478 Lines: 34 On Thu, Mar 10, 2005 at 09:49:53PM -0500, Dave Jones wrote: > On Fri, Mar 11, 2005 at 01:40:24PM +1100, Benjamin Herrenschmidt wrote: > > > > > After it does that pci_dev_put on the from, it does another pci_dev_get > > > on 'dev', which is what my put was releasing. > > > > > > Or am I terribly confused ? > > > > Well, pci_get_class() put's the passed-in device and get's() the > > returned one. So if you run it in a loop, you should never have to > > either get or put. When you exit the loop with a valid pci_dev, though, > > you should definitely put() it after you're done with it, but this is > > something that should be done only for that specific instance and after > > you are finished with it... > > Yeah. Makes perfect sense now I've had it spelled out for me :-) > I think Linus is right though that some extra bullet-proofing in kref_put > to BUG() if it goes negative would've caught this. I wonder if anyone > else has fallen into this trap. It can't go negative. If it hits zero, the object is freed and cleaned up. If you have slab debugging enabled, the next time you try to access this pointer, boom. So no atomic negative checks will help with kref/kobject code, sorry. thanks, greg k-h - 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/