Skip to content

Commit f58b59c

Browse files
xtfengtorvalds
authored andcommitted
swapfile: fix name leak in swapoff
There's a name leak introduced by commit 91a27b2 ("vfs: define struct filename and have getname() return it"). Add the missing putname. [akpm@linux-foundation.org: cleanup] Signed-off-by: Xiaotian Feng <dannyfeng@tencent.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent bea8c15 commit f58b59c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎mm/swapfile.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,9 +1494,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
14941494
BUG_ON(!current->mm);
14951495

14961496
pathname = getname(specialfile);
1497-
err = PTR_ERR(pathname);
14981497
if (IS_ERR(pathname))
1499-
goto out;
1498+
return PTR_ERR(pathname);
15001499

15011500
victim = file_open_name(pathname, O_RDWR|O_LARGEFILE, 0);
15021501
err = PTR_ERR(victim);
@@ -1608,6 +1607,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
16081607
out_dput:
16091608
filp_close(victim, NULL);
16101609
out:
1610+
putname(pathname);
16111611
return err;
16121612
}
16131613

0 commit comments

Comments
 (0)