Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755511AbXLDP2g (ORCPT ); Tue, 4 Dec 2007 10:28:36 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753750AbXLDP21 (ORCPT ); Tue, 4 Dec 2007 10:28:27 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:46162 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753206AbXLDP2Z (ORCPT ); Tue, 4 Dec 2007 10:28:25 -0500 Date: Tue, 4 Dec 2007 10:28:24 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Cornelia Huck cc: Greg KH , Kay Sievers , Kernel development list , Jonathan Corbet , Randy Dunlap Subject: Re: [RFC] kobject: add kobject_init_ng, kobject_add_ng, and kobject_init_and_add functions In-Reply-To: <20071204110112.14488ece@gondolin.boeblingen.de.ibm.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1531 Lines: 34 On Tue, 4 Dec 2007, Cornelia Huck wrote: > > > > > + * If the function is successful, the only way to properly clean up the > > > > > + * memory is with a call to kobject_del(). > > > > > > > > In which case kobject_put() isn't needed? > > > > > > kobject_del() should only undo what kobject_add() did. So kobject_put() > > > will still be needed to clean up the memory. Perhaps the wording should > > > be: > > > > > > If the function is successful, the only way to properly clean up the > > > kobject is to call kobject_del() for removing the kobject from the > > > hierarchy and to subsequently call kobject_put() to clean up the memory. > > > > But that's not what the code does today in the kobject_del() function. > > Hm, if I'm not completely confused, kobject_del() just gives up the > extra reference obtained by kobject_add(). That leaves the initial > reference we got via kobject_init(_ng)(). If we want to clean up the > memory, we need to give up that reference as well. That's right. Furthermore there are other parts of the kernel that expect to do the kobject_del() and the final kobject_put() separately. For example, the driver core does kobject_del() as part of device_del() and then it does the final kobject_put() as part of put_device(). Alan Stern -- 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/