From: Greg KH <greg@kroah.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, gregkh@suse.de
Subject: Re: mmotm 2008-12-17-16-41 uploaded
Date: Thu, 18 Dec 2008 14:23:29 -0800 [thread overview]
Message-ID: <20081218222329.GA1398@kroah.com> (raw)
In-Reply-To: <20081218131015.735da05e.kamezawa.hiroyu@jp.fujitsu.com>
On Thu, Dec 18, 2008 at 01:10:15PM +0900, KAMEZAWA Hiroyuki wrote:
> On Wed, 17 Dec 2008 16:41:54 -0800
> akpm@linux-foundation.org wrote:
>
> > The mm-of-the-moment snapshot 2008-12-17-16-41 has been uploaded to
> >
> > http://userweb.kernel.org/~akpm/mmotm/
> >
> > and will soon be available at
> >
> > git://git.zen-sources.org/zen/mmotm.git
> >
>
> This was necessary. I'm not sure my patch description is corrcect...
> but this helps me ;)
> This change kfree(dev->p) comes from linux-next.
>
> ==
> From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>
> dev->release() may free struct dev itself. To free dev->p
> in safe way, remember dev->p.
>
> Signed-off-by:KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> ---
> drivers/base/core.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> Index: mmotm-2.6.28-Dec17/drivers/base/core.c
> ===================================================================
> --- mmotm-2.6.28-Dec17.orig/drivers/base/core.c
> +++ mmotm-2.6.28-Dec17/drivers/base/core.c
> @@ -109,6 +109,7 @@ static struct sysfs_ops dev_sysfs_ops =
> static void device_release(struct kobject *kobj)
> {
> struct device *dev = to_dev(kobj);
> + struct device_private *p = dev->p;
>
> if (dev->release)
> dev->release(dev);
> @@ -116,11 +117,13 @@ static void device_release(struct kobjec
> dev->type->release(dev);
> else if (dev->class && dev->class->dev_release)
> dev->class->dev_release(dev);
> - else
> + else {
> WARN(1, KERN_ERR "Device '%s' does not have a release() "
> "function, it is broken and must be fixed.\n",
> dev_name(dev));
> - kfree(dev->p);
> + return;
> + }
> + kfree(p);
You have a memory leak for when there is no release function for a
device, don't return if that happens.
I've now fixed this up in my tree, thanks for pointing it out.
greg k-h
next prev parent reply other threads:[~2008-12-18 22:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-18 0:41 mmotm 2008-12-17-16-41 uploaded akpm
2008-12-18 4:10 ` KAMEZAWA Hiroyuki
2008-12-18 22:23 ` Greg KH [this message]
2008-12-19 0:11 ` KAMEZAWA Hiroyuki
2008-12-19 0:32 ` Greg KH
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=20081218222329.GA1398@kroah.com \
--to=greg@kroah.com \
--cc=akpm@linux-foundation.org \
--cc=gregkh@suse.de \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.