Fix mountpoint reference leakage in linkat
authorOleg Drokin <green@linuxhacker.ru>
Fri, 31 Jan 2014 20:41:58 +0000 (15:41 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 31 Jan 2014 22:33:13 +0000 (17:33 -0500)
Recent changes to retry on ESTALE in linkat
(commit 442e31ca5a49e398351b2954b51f578353fdf210)
introduced a mountpoint reference leak and a small memory
leak in case a filesystem link operation returns ESTALE
which is pretty normal for distributed filesystems like
lustre, nfs and so on.
Free old_path in such a case.

[AV: there was another missing path_put() nearby - on the previous
goto retry]

Signed-off-by: Oleg Drokin: <green@linuxhacker.ru>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c

index 445d9bb..d580df2 100644 (file)
@@ -3926,10 +3926,13 @@ out_dput:
        done_path_create(&new_path, new_dentry);
        if (delegated_inode) {
                error = break_deleg_wait(&delegated_inode);
-               if (!error)
+               if (!error) {
+                       path_put(&old_path);
                        goto retry;
+               }
        }
        if (retry_estale(error, how)) {
+               path_put(&old_path);
                how |= LOOKUP_REVAL;
                goto retry;
        }