From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Ming Lei <ming.lei@canonical.com>
Cc: Dave Jones <davej@redhat.com>,
linux-kernel@vger.kernel.org,
Sasha Levin <levinsasha928@gmail.com>
Subject: Re: [PATCH] sysfs: check if one entry has been removed before freeing
Date: Tue, 2 Apr 2013 22:35:34 -0700 [thread overview]
Message-ID: <20130403053534.GA8091@kroah.com> (raw)
In-Reply-To: <CACVXFVPOC=d3-1UBu6UbqJXMS2gG=DXnBJeuLaFc3R4QKAzWyg@mail.gmail.com>
On Wed, Apr 03, 2013 at 11:52:39AM +0800, Ming Lei wrote:
> On Wed, Apr 3, 2013 at 11:04 AM, Dave Jones <davej@redhat.com> wrote:
> > On Wed, Apr 03, 2013 at 10:58:23AM +0800, Ming Lei wrote:
> >
> > > diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
> > > index 1bf016b..328ef9b 100644
> > > --- a/fs/sysfs/dir.c
> > > +++ b/fs/sysfs/dir.c
> > > @@ -268,6 +268,13 @@ void release_sysfs_dirent(struct sysfs_dirent * sd)
> > > */
> > > parent_sd = sd->s_parent;
> > >
> > > + if (unlikely(!(sd->s_flags & SYSFS_FLAG_REMOVED))) {
> > > + printk(KERN_ERR "sysfs: free using entry: %s/%s\n",
> > > + parent_sd ? parent_sd->s_name : "",
> > > + sd->s_name);
> > > + BUG();
> > > + }
> >
> > Please use WARN instead of BUG. For an in-ram filesystem like
> > sysfs, there's no real reason to lock-up the machine in this way
> > making it harder to debug.
>
> If WARN is used, the freed memory will be allocated to other
> kernel components, then sysfs may change the memory and cause
> destruction, so maybe it is better to use BUG to stop kernel.
No, it's never ok to call BUG(), sorry, please fix this.
greg k-h
next prev parent reply other threads:[~2013-04-03 5:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-03 2:58 [PATCH] sysfs: check if one entry has been removed before freeing Ming Lei
2013-04-03 3:04 ` Dave Jones
2013-04-03 3:52 ` Ming Lei
2013-04-03 5:35 ` Greg Kroah-Hartman [this message]
2013-04-03 7:05 ` Ming Lei
2013-04-03 16:08 ` Greg Kroah-Hartman
2013-04-04 9:36 ` Ming Lei
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=20130403053534.GA8091@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=davej@redhat.com \
--cc=levinsasha928@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@canonical.com \
/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