mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Dake <sdake@mvista.com>
To: Patrick Mochel <mochel@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH} fix defect with kobject memory leaks during del_gendisk
Date: Thu, 25 Sep 2003 11:43:04 -0700	[thread overview]
Message-ID: <1064515384.4763.28.camel@persist.az.mvista.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0309251023220.947-100000@localhost.localdomain>

On Thu, 2003-09-25 at 10:26, Patrick Mochel wrote:
> > Attached is a patch which fixes a few memory leaks in 2.6.0-test5. 
> > Comments are welcome as to whether or not this patch is the right
> > solution.
> > 
> > I added the ability to linux MD to generate add and remove hotplug calls
> > on RAID START and STOPs.  To achieve this, I use the del_gendisk call
> > which deletes the gendisk, delete the children kobjects, and delete the
> > parent (in this case, mdX) kobject.
> > 
> > Unfortunately it appears that del_gendisk uses kobject_del to delete the
> > kobject.  If the kobject has a ktype release function, it is not called
> > in the kobject_del call path, but only in kobject_unregister.
> > 
> > This patch changes the functionality so the release function (in this
> > case the block device release function in drivers/block/genhd.c) is
> > called by changing the kobject_del to kobject_unregister.
> 
> It is not the right thing to do, as Christoph pointed out. Gendisks have a 
> lifetime longer than the time between add_disk() and del_gendisk(). They 
> are created before they are added, and the objects may persist longer 
> after they have been removed from view. 
> 
> To delete the last reference, the MD layer should be calling put_disk(), 
> which will trigger release to happen. 
> 
> Your patch will actually cause other bugs, since the final put_disk() of 
> other block drivers will now be called on already freed memory.
> 
> 
> 	Pat
> 
> 
Thanks good call..  Didn't see the put_disk call but it makes sense now.

-steve


      reply	other threads:[~2003-09-25 18:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-24 23:02 Steven Dake
2003-09-25  6:23 ` Christoph Hellwig
2003-09-25 18:04   ` Steven Dake
2003-09-25 17:26 ` Patrick Mochel
2003-09-25 18:43   ` Steven Dake [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1064515384.4763.28.camel@persist.az.mvista.com \
    --to=sdake@mvista.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®