From owner-freebsd-hackers@FreeBSD.ORG Thu May 31 08:26:46 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EBA9C106564A for ; Thu, 31 May 2012 08:26:46 +0000 (UTC) (envelope-from nkoch@demig.de) Received: from h949823.serverkompetenz.net (demig.de [85.214.63.38]) by mx1.freebsd.org (Postfix) with ESMTP id 41B838FC0A for ; Thu, 31 May 2012 08:26:45 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=demig.de; b=C70vGvAMd+N9UZOz9Qjda3OAyl5TqLrETaX9HAxvJfQij0uId0dU/B3OBFNReJ/pghrx7IPaUBpwSKZ6Jz6HK6SmxToO3zSYDppLlHmW79FIUxmiIujMPbSKyozl1Iw6; h=Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:X-Enigmail-Version:Content-Type:Content-Transfer-Encoding:X-Scanned-By; Received: (qmail 29901 invoked from network); 31 May 2012 10:20:03 +0200 Received: from ip-78-94-60-110.unitymediagroup.de (HELO firewall.demig.intra) (78.94.60.110) by demig.de with (DHE-RSA-AES256-SHA encrypted) SMTP; 31 May 2012 10:20:03 +0200 Received: from entw-pr.demig.intra (srv-pr-1 [192.168.148.236]) by firewall.demig.intra (8.14.4/8.14.4) with ESMTP id q4V8Jj8n093858 for ; Thu, 31 May 2012 10:19:45 +0200 (CEST) (envelope-from nkoch@demig.de) Received: from [192.168.148.83] (ws-pr-3a [192.168.148.83]) by entw-pr.demig.intra (8.14.2/8.13.4) with ESMTP id q4V8JjR4019095 for ; Thu, 31 May 2012 10:19:45 +0200 (CEST) (envelope-from nkoch@demig.de) Message-ID: <4FC729A2.30205@demig.de> Date: Thu, 31 May 2012 10:19:46 +0200 From: Norbert Koch User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org X-Enigmail-Version: 1.4.1 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.73 on 192.168.148.235 Subject: bus device/ivars X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 May 2012 08:26:47 -0000 Hello, I have written a bus device driver which itself is a pci driver. Child devices may allocate resources from my bus device. My bus device does the usual management of resources through the children's ivars. My question is this: The bus device mallocs the children's ivars in bus_add_child and frees the ivars in either bus_detach or bus_child_detached. The children are added in identify methods through BUS_ADD_CHILD. As I understand the code the bus device's bus_child_detached method is called in device_delete_child only if the child device is already attached. So, there seems to be a memory leak if I delete the child device in either identify or probe. My current solution (not tested yet) is to explicitly call BUS_CHILD_DETACHED in the child device's code before calling device_delete_child. Is this the correct way or is there a more elegant/cleaner solution? I expected to find something like a BUS_DELETE_CHILD method. Thank you for any advice, Norbert Koch