afs_mntpt_follow_link() actually does mntput before dput, which is wrong.
Signed-off-by: Jan Blunck <[email protected]>
Signed-off-by: Andreas Gruenbacher <[email protected]>
---
fs/afs/mntpt.c | 3 +--
fs/namei.c | 15 +++++----------
2 files changed, 6 insertions(+), 12 deletions(-)
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -235,8 +235,7 @@ static void *afs_mntpt_follow_link(struc
err = do_add_mount(newmnt, nd, MNT_SHRINKABLE, &afs_vfsmounts);
switch (err) {
case 0:
- mntput(nd->lookup.path.mnt);
- dput(nd->lookup.path.dentry);
+ pathput(&nd->lookup.path);
nd->lookup.path.mnt = newmnt;
nd->lookup.path.dentry = dget(newmnt->mnt_root);
schedule_delayed_work(&afs_mntpt_expiry_timer,
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -610,8 +610,7 @@ static __always_inline int __do_follow_l
if (dentry->d_inode->i_op->put_link)
dentry->d_inode->i_op->put_link(dentry, nd, cookie);
}
- dput(dentry);
- mntput(path->mnt);
+ pathput(path);
return error;
}
@@ -1016,8 +1015,7 @@ static int fastcall link_path_walk(const
result = __link_path_walk(name, nd);
}
- dput(save.lookup.path.dentry);
- mntput(save.lookup.path.mnt);
+ pathput(&save.lookup.path);
return result;
}
@@ -1038,8 +1036,7 @@ static int __emul_lookup_dentry(const ch
return 0; /* something went wrong... */
if (!nd->lookup.path.dentry->d_inode || S_ISDIR(nd->lookup.path.dentry->d_inode->i_mode)) {
- struct dentry *old_dentry = nd->lookup.path.dentry;
- struct vfsmount *old_mnt = nd->lookup.path.mnt;
+ struct path old_path = nd->lookup.path;
struct qstr last = nd->last;
int last_type = nd->last_type;
struct fs_struct *fs = current->fs;
@@ -1055,14 +1052,12 @@ static int __emul_lookup_dentry(const ch
read_unlock(&fs->lock);
if (path_walk(name, nd) == 0) {
if (nd->lookup.path.dentry->d_inode) {
- dput(old_dentry);
- mntput(old_mnt);
+ pathput(&old_path);
return 1;
}
pathput(&nd->lookup.path);
}
- nd->lookup.path.dentry = old_dentry;
- nd->lookup.path.mnt = old_mnt;
+ nd->lookup.path = old_path;
nd->last = last;
nd->last_type = last_type;
}
On Fri, Aug 10, 2007 at 04:22:10PM +0200, Andreas Gruenbacher wrote:
> afs_mntpt_follow_link() actually does mntput before dput, which is wrong.
Please send a fix to Dave to fix this for 2.6.24 and stable even without
introducing pathput just yet.
The actual patch is fine.
David,
dput must be called before mntput here. Please consider for 2.6.24 and stable.
Signed-off-by: Andreas Gruenbacher <[email protected]>
---
fs/afs/mntpt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -235,8 +235,8 @@ static void *afs_mntpt_follow_link(struc
err = do_add_mount(newmnt, nd, MNT_SHRINKABLE, &afs_vfsmounts);
switch (err) {
case 0:
- mntput(nd->mnt);
dput(nd->dentry);
+ mntput(nd->mnt);
nd->mnt = newmnt;
nd->dentry = dget(newmnt->mnt_root);
schedule_delayed_work(&afs_mntpt_expiry_timer,
Andreas Gruenbacher <[email protected]> wrote:
> dput must be called before mntput here. Please consider for 2.6.24 and stable.
>
> Signed-off-by: Andreas Gruenbacher <[email protected]>
Fine by me.
Acked-By: David Howells <[email protected]>
From: Andreas Gruenbacher <[email protected]>
dput must be called before mntput here. Please consider for 2.6.24 and stable.
Signed-off-by: Andreas Gruenbacher <[email protected]>
Acked-By: David Howells <[email protected]>
---
fs/afs/mntpt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -235,8 +235,8 @@ static void *afs_mntpt_follow_link(struc
err = do_add_mount(newmnt, nd, MNT_SHRINKABLE, &afs_vfsmounts);
switch (err) {
case 0:
- mntput(nd->mnt);
dput(nd->dentry);
+ mntput(nd->mnt);
nd->mnt = newmnt;
nd->dentry = dget(newmnt->mnt_root);
schedule_delayed_work(&afs_mntpt_expiry_timer,