Skip to contentSkip to conversation

NFS: Fix memroy leak for double mounts

PATCH Applied Kinglong Mee 2 participants 2 messages Apr 15, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFS: Fix memroy leak for double mounts

When double mounting same nfs filesystem, the devname saved in d_fsdata will be lost.The second mount should not change the devname that be saved in d_fsdata.

---
 fs/nfs/getroot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/getroot.c +0 -0
index 66984a9..b94f804 100644
@@ -120,7 +120,8 @@ struct dentry *nfs_get_root(struct super_block *sb,

struct nfs_fh *mntfh,

security_d_instantiate(ret, inode);
spin_lock(&ret->d_lock);
- if (IS_ROOT(ret) && !(ret->d_flags & DCACHE_NFSFS_RENAMED)) {
+ if (IS_ROOT(ret) && !ret->d_fsdata &&
+ !(ret->d_flags & DCACHE_NFSFS_RENAMED)) {
ret->d_fsdata = name;
name = NULL;
}

Signature · 1 line
1.9.0
#1 lore raw
Quoted 23 lines · Kinglong Mee

When double mounting same nfs filesystem, the devname saved in d_fsdata will be lost.The second mount should not change the devname that be saved in d_fsdata.

---
 fs/nfs/getroot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/getroot.c +2 -1
index 66984a9..b94f804 100644
@@ -120,7 +120,8 @@ struct dentry *nfs_get_root(struct super_block *sb,
 struct nfs_fh *mntfh,
 
 	security_d_instantiate(ret, inode);
 	spin_lock(&ret->d_lock);
-	if (IS_ROOT(ret) && !(ret->d_flags & DCACHE_NFSFS_RENAMED)) {
+	if (IS_ROOT(ret) && !ret->d_fsdata &&
+	    !(ret->d_flags & DCACHE_NFSFS_RENAMED)) {
 		ret->d_fsdata = name;
 		name = NULL;
Quoted 1 line

}

Applied. Thanks!

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]