diff options
author | Oleg Drokin <green@linuxhacker.ru> | 2006-01-09 23:52:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-10 11:01:41 -0500 |
commit | e866cfa939de7f52c154a9495eb5767f89abf453 (patch) | |
tree | 331c6c08848597ea5674ebccb51f31a045bd1e30 | |
parent | 632d6407afb58ef125bf7e82a2e8af27d0704b56 (diff) |
[PATCH] d_instantiate_unique / NFS inode leakage
If we have found aliased dentry that we return, inode reference is not
dropped and inode is not attached anywhere, so it seems the reference to
inode is leaked in that case.
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>,
Cc: <viro@parcelfarce.linux.theplanet.co.uk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/dcache.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 1536f15c4d4c..134d6775183f 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -808,10 +808,14 @@ void d_instantiate(struct dentry *entry, struct inode * inode) | |||
808 | * | 808 | * |
809 | * Fill in inode information in the entry. On success, it returns NULL. | 809 | * Fill in inode information in the entry. On success, it returns NULL. |
810 | * If an unhashed alias of "entry" already exists, then we return the | 810 | * If an unhashed alias of "entry" already exists, then we return the |
811 | * aliased dentry instead. | 811 | * aliased dentry instead and drop one reference to inode. |
812 | * | 812 | * |
813 | * Note that in order to avoid conflicts with rename() etc, the caller | 813 | * Note that in order to avoid conflicts with rename() etc, the caller |
814 | * had better be holding the parent directory semaphore. | 814 | * had better be holding the parent directory semaphore. |
815 | * | ||
816 | * This also assumes that the inode count has been incremented | ||
817 | * (or otherwise set) by the caller to indicate that it is now | ||
818 | * in use by the dcache. | ||
815 | */ | 819 | */ |
816 | struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode) | 820 | struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode) |
817 | { | 821 | { |
@@ -838,6 +842,7 @@ struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode) | |||
838 | dget_locked(alias); | 842 | dget_locked(alias); |
839 | spin_unlock(&dcache_lock); | 843 | spin_unlock(&dcache_lock); |
840 | BUG_ON(!d_unhashed(alias)); | 844 | BUG_ON(!d_unhashed(alias)); |
845 | iput(inode); | ||
841 | return alias; | 846 | return alias; |
842 | } | 847 | } |
843 | list_add(&entry->d_alias, &inode->i_dentry); | 848 | list_add(&entry->d_alias, &inode->i_dentry); |