Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 6845
b: refs/heads/master
c: e2244ec
h: refs/heads/master
i:
  6843: 0de52cb
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Sep 5, 2005
1 parent c1a8fc7 commit e49c491
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b0d9bcd4bb79a7834f8492f2ae5c2655a551f23d
refs/heads/master: e2244ec2efa4ee1edf391d0001d314933e2b2974
25 changes: 16 additions & 9 deletions trunk/mm/swapfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,8 +1008,9 @@ static int setup_swap_extents(struct swap_info_struct *sis)
}
ret = 0;
if (page_no == 0)
ret = -EINVAL;
page_no = 1; /* force Empty message */
sis->max = page_no;
sis->pages = page_no - 1;
sis->highest_bit = page_no - 1;
done:
sis->curr_swap_extent = list_entry(sis->extent_list.prev,
Expand Down Expand Up @@ -1446,6 +1447,10 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
p->highest_bit = maxpages - 1;

error = -EINVAL;
if (!maxpages)
goto bad_swap;
if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode))
goto bad_swap;
if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES)
goto bad_swap;

Expand All @@ -1470,25 +1475,27 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
if (error)
goto bad_swap;
}

if (swapfilesize && maxpages > swapfilesize) {
printk(KERN_WARNING
"Swap area shorter than signature indicates\n");
error = -EINVAL;
goto bad_swap;
}
if (nr_good_pages) {
p->swap_map[0] = SWAP_MAP_BAD;
p->max = maxpages;
p->pages = nr_good_pages;
error = setup_swap_extents(p);
if (error)
goto bad_swap;
nr_good_pages = p->pages;
}
if (!nr_good_pages) {
printk(KERN_WARNING "Empty swap-file\n");
error = -EINVAL;
goto bad_swap;
}
p->swap_map[0] = SWAP_MAP_BAD;
p->max = maxpages;
p->pages = nr_good_pages;

error = setup_swap_extents(p);
if (error)
goto bad_swap;

down(&swapon_sem);
swap_list_lock();
Expand Down

0 comments on commit e49c491

Please sign in to comment.