From: viro@parcelfarce.linux.theplanet.co.uk
To: Maneesh Soni <maneesh@in.ibm.com>
Cc: Greg KH <greg@kroah.com>, Jeff Garzik <jgarzik@pobox.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] fix sysfs symlinks
Date: Fri, 23 Apr 2004 10:26:41 +0100 [thread overview]
Message-ID: <20040423092641.GM17014@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <20040423085218.GB27638@in.ibm.com>
On Fri, Apr 23, 2004 at 02:22:18PM +0530, Maneesh Soni wrote:
> @@ -136,6 +138,12 @@ restart:
> */
> spin_unlock(&dcache_lock);
> d_delete(d);
ITYM "d_drop(d)" here. Right now these are equivalent (and d_drop() is
less work) since we are holding at least two references to d; if/when
we stop pinning leaves of the tree in core, the check below will become
unsafe with d_delete().
> new_dentry = sysfs_get_dentry(parent, new_name);
> - d_move(kobj->dentry, new_dentry);
> - kobject_set_name(kobj,new_name);
> + if (!IS_ERR(new_dentry)) {
> + down_write(&sysfs_rename_sem);
> + d_move(kobj->dentry, new_dentry);
> + kobject_set_name(kobj,new_name);
> + up_write(&sysfs_rename_sem);
> + }
> up(&parent->d_inode->i_sem);
> }
BTW, the above leaks because of unbalanced sysfs_get_dentry(). You need
a dput() in there.
> diff -puN fs/sysfs/inode.c~sysfs-symlinks-fix fs/sysfs/inode.c
> --- linux-2.6.6-rc2-mm1/fs/sysfs/inode.c~sysfs-symlinks-fix 2004-04-23 10:22:41.000000000 +0530
> +++ linux-2.6.6-rc2-mm1-maneesh/fs/sysfs/inode.c 2004-04-23 11:03:38.000000000 +0530
> @@ -97,6 +97,11 @@ void sysfs_hash_and_remove(struct dentry
> atomic_read(&victim->d_count));
>
> d_delete(victim);
> + /* release the target kobject in case of
> + * a symlink
> + */
> + if (S_ISLNK(victim->d_inode->i_mode))
> + kobject_put(victim->d_fsdata);
Same s/d_delete/d_drop/ issue.
> simple_unlink(dir->d_inode,victim);
> }
> @@ -70,11 +70,13 @@ void sysfs_remove_group(struct kobject *
> else
> dir = dget(kobj->dentry);
>
> - remove_files(dir,grp);
> - if (grp->name)
> - sysfs_remove_subdir(dir);
> - /* release the ref. taken in this routine */
> - dput(dir);
> + if (dir && !IS_ERR(dir)) {
> + remove_files(dir,grp);
> + if (grp->name)
> + sysfs_remove_subdir(dir);
> + /* release the ref. taken in this routine */
> + dput(dir);
> + }
> }
Hmm... I thought that's what
if (error)
return error;
several lines above had been about. Can we get there with NULL or ERR_PTR()
in dir?
next prev parent reply other threads:[~2004-04-23 9:26 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-13 12:40 Maneesh Soni
2004-04-13 13:36 ` viro
2004-04-14 6:40 ` Maneesh Soni
2004-04-14 7:02 ` viro
2004-04-14 7:17 ` Maneesh Soni
2004-04-14 7:27 ` viro
2004-04-15 8:17 ` Russell King
2004-04-15 10:38 ` viro
2004-04-15 15:19 ` Russell King
2004-04-15 16:10 ` Greg KH
2004-04-15 16:13 ` viro
2004-04-15 19:14 ` viro
2004-04-15 21:27 ` Greg KH
2004-04-17 6:15 ` Rusty Russell
2004-04-17 19:39 ` viro
2004-04-17 23:45 ` Rusty Russell
2004-04-15 22:02 ` Greg KH
2004-04-16 15:24 ` viro
2004-04-16 18:03 ` Horst von Brand
2004-04-16 18:07 ` viro
2004-04-16 22:37 ` Greg KH
2004-04-16 23:46 ` viro
2004-04-17 0:03 ` Jeff Garzik
2004-04-17 8:07 ` Russell King
2004-04-17 8:22 ` viro
2004-04-20 16:16 ` Greg KH
2004-04-21 10:11 ` Maneesh Soni
2004-04-22 21:37 ` viro
2004-04-23 8:52 ` Maneesh Soni
2004-04-23 9:26 ` viro [this message]
2004-04-29 13:03 ` Maneesh Soni
2004-04-29 15:41 ` viro
2004-04-30 10:05 ` Maneesh Soni
2004-04-30 10:13 ` [RFC 0/2] kobject_set_name - error handling Maneesh Soni
2004-04-30 10:14 ` [RFC 1/2] " Maneesh Soni
2004-04-30 10:17 ` [RFC 2/2] " Maneesh Soni
2004-05-04 13:08 ` Maneesh Soni
2004-04-30 12:48 ` [RFC 1/2] " Dmitry Torokhov
2004-05-04 5:39 ` Maneesh Soni
2004-05-04 9:19 ` Maneesh Soni
2004-05-07 22:25 ` Greg KH
2003-05-09 10:05 ` Maneesh Soni
2003-05-09 10:09 ` [RFC 2/2] sysfs_rename_dir-cleanup Maneesh Soni
2004-05-11 23:33 ` Greg KH
2004-10-07 5:16 ` Maneesh Soni
2004-10-07 5:38 ` Maneesh Soni
2004-05-14 19:10 ` Greg KH
2004-05-11 23:32 ` [RFC 1/2] kobject_set_name - error handling Greg KH
2004-04-17 0:15 ` [RFC] fix sysfs symlinks 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=20040423092641.GM17014@parcelfarce.linux.theplanet.co.uk \
--to=viro@parcelfarce.linux.theplanet.co.uk \
--cc=greg@kroah.com \
--cc=jgarzik@pobox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maneesh@in.ibm.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
all inboxes | Powered by JetHome®