diff options
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r-- | mm/swapfile.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index 5d3a7f23e..55ef476a3 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -407,11 +407,11 @@ asmlinkage long sys_swapoff(const char * specialfile) if (!capable(CAP_SYS_ADMIN)) return -EPERM; + lock_kernel(); err = user_path_walk(specialfile, &nd); if (err) goto out; - lock_kernel(); prev = -1; swap_list_lock(); for (type = swap_list.head; type >= 0; type = swap_info[type].next) { @@ -478,9 +478,9 @@ asmlinkage long sys_swapoff(const char * specialfile) err = 0; out_dput: - unlock_kernel(); path_release(&nd); out: + unlock_kernel(); return err; } @@ -555,6 +555,7 @@ asmlinkage long sys_swapon(const char * specialfile, int swap_flags) unsigned long maxpages; int swapfilesize; struct block_device *bdev = NULL; + char *name; if (!capable(CAP_SYS_ADMIN)) return -EPERM; @@ -585,7 +586,14 @@ asmlinkage long sys_swapon(const char * specialfile, int swap_flags) } else { p->prio = --least_priority; } - error = user_path_walk(specialfile, &nd); + name = getname(specialfile); + error = PTR_ERR(name); + if (IS_ERR(name)) + goto bad_swap_2; + error = 0; + if (path_init(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd)) + error = path_walk(name, &nd); + putname(name); if (error) goto bad_swap_2; |