aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index b261e55e0b82..e4dc94996c58 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1916,14 +1916,14 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
1916 return PTR_ERR(p); 1916 return PTR_ERR(p);
1917 1917
1918 name = getname(specialfile); 1918 name = getname(specialfile);
1919 error = PTR_ERR(name);
1920 if (IS_ERR(name)) { 1919 if (IS_ERR(name)) {
1920 error = PTR_ERR(name);
1921 name = NULL; 1921 name = NULL;
1922 goto bad_swap_2; 1922 goto bad_swap_2;
1923 } 1923 }
1924 swap_file = filp_open(name, O_RDWR|O_LARGEFILE, 0); 1924 swap_file = filp_open(name, O_RDWR|O_LARGEFILE, 0);
1925 error = PTR_ERR(swap_file);
1926 if (IS_ERR(swap_file)) { 1925 if (IS_ERR(swap_file)) {
1926 error = PTR_ERR(swap_file);
1927 swap_file = NULL; 1927 swap_file = NULL;
1928 goto bad_swap_2; 1928 goto bad_swap_2;
1929 } 1929 }
@@ -1932,17 +1932,17 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
1932 mapping = swap_file->f_mapping; 1932 mapping = swap_file->f_mapping;
1933 inode = mapping->host; 1933 inode = mapping->host;
1934 1934
1935 error = -EBUSY;
1936 for (i = 0; i < nr_swapfiles; i++) { 1935 for (i = 0; i < nr_swapfiles; i++) {
1937 struct swap_info_struct *q = swap_info[i]; 1936 struct swap_info_struct *q = swap_info[i];
1938 1937
1939 if (q == p || !q->swap_file) 1938 if (q == p || !q->swap_file)
1940 continue; 1939 continue;
1941 if (mapping == q->swap_file->f_mapping) 1940 if (mapping == q->swap_file->f_mapping) {
1941 error = -EBUSY;
1942 goto bad_swap; 1942 goto bad_swap;
1943 }
1943 } 1944 }
1944 1945
1945 error = -EINVAL;
1946 if (S_ISBLK(inode->i_mode)) { 1946 if (S_ISBLK(inode->i_mode)) {
1947 bdev = bdgrab(I_BDEV(inode)); 1947 bdev = bdgrab(I_BDEV(inode));
1948 error = blkdev_get(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL, 1948 error = blkdev_get(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL,
@@ -1966,6 +1966,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
1966 goto bad_swap; 1966 goto bad_swap;
1967 } 1967 }
1968 } else { 1968 } else {
1969 error = -EINVAL;
1969 goto bad_swap; 1970 goto bad_swap;
1970 } 1971 }
1971 1972