aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 5e13bff1764c..058a9dfefefd 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1928,7 +1928,7 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
1928 1928
1929 if (memcmp("SWAPSPACE2", swap_header->magic.magic, 10)) { 1929 if (memcmp("SWAPSPACE2", swap_header->magic.magic, 10)) {
1930 printk(KERN_ERR "Unable to find swap-space signature\n"); 1930 printk(KERN_ERR "Unable to find swap-space signature\n");
1931 goto bad_swap; 1931 return 0;
1932 } 1932 }
1933 1933
1934 /* swap partition endianess hack... */ 1934 /* swap partition endianess hack... */
@@ -1944,7 +1944,7 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
1944 printk(KERN_WARNING 1944 printk(KERN_WARNING
1945 "Unable to handle swap header version %d\n", 1945 "Unable to handle swap header version %d\n",
1946 swap_header->info.version); 1946 swap_header->info.version);
1947 goto bad_swap; 1947 return 0;
1948 } 1948 }
1949 1949
1950 p->lowest_bit = 1; 1950 p->lowest_bit = 1;
@@ -1976,22 +1976,19 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
1976 p->highest_bit = maxpages - 1; 1976 p->highest_bit = maxpages - 1;
1977 1977
1978 if (!maxpages) 1978 if (!maxpages)
1979 goto bad_swap; 1979 return 0;
1980 swapfilepages = i_size_read(inode) >> PAGE_SHIFT; 1980 swapfilepages = i_size_read(inode) >> PAGE_SHIFT;
1981 if (swapfilepages && maxpages > swapfilepages) { 1981 if (swapfilepages && maxpages > swapfilepages) {
1982 printk(KERN_WARNING 1982 printk(KERN_WARNING
1983 "Swap area shorter than signature indicates\n"); 1983 "Swap area shorter than signature indicates\n");
1984 goto bad_swap; 1984 return 0;
1985 } 1985 }
1986 if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode)) 1986 if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode))
1987 goto bad_swap; 1987 return 0;
1988 if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES) 1988 if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES)
1989 goto bad_swap; 1989 return 0;
1990 1990
1991 return maxpages; 1991 return maxpages;
1992
1993bad_swap:
1994 return 0;
1995} 1992}
1996 1993
1997SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) 1994SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)