aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCesar Eduardo Barros <cesarb@cesarb.net>2011-03-22 19:33:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-22 20:44:07 -0400
commit87ade72a799a9a895b4a60918c32b43d3dfc3324 (patch)
tree3110f7526fc3581962232b39567fee2fb95c44aa
parent4d0e1e10752ca487d83d1ab2a1d4ae6d664e1cc0 (diff)
sys_swapon: simplify error flow in claim_swapfile()
Since there is no cleanup to do, there is no reason to jump to a label. Return directly instead. Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net> Tested-by: Eric B Munson <emunson@mgebm.net> Acked-by: Eric B Munson <emunson@mgebm.net> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Hugh Dickins <hughd@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/swapfile.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index fc687b234eb5..61a604c12a96 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1900,30 +1900,22 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
1900 sys_swapon); 1900 sys_swapon);
1901 if (error < 0) { 1901 if (error < 0) {
1902 p->bdev = NULL; 1902 p->bdev = NULL;
1903 error = -EINVAL; 1903 return -EINVAL;
1904 goto bad_swap;
1905 } 1904 }
1906 p->old_block_size = block_size(p->bdev); 1905 p->old_block_size = block_size(p->bdev);
1907 error = set_blocksize(p->bdev, PAGE_SIZE); 1906 error = set_blocksize(p->bdev, PAGE_SIZE);
1908 if (error < 0) 1907 if (error < 0)
1909 goto bad_swap; 1908 return error;
1910 p->flags |= SWP_BLKDEV; 1909 p->flags |= SWP_BLKDEV;
1911 } else if (S_ISREG(inode->i_mode)) { 1910 } else if (S_ISREG(inode->i_mode)) {
1912 p->bdev = inode->i_sb->s_bdev; 1911 p->bdev = inode->i_sb->s_bdev;
1913 mutex_lock(&inode->i_mutex); 1912 mutex_lock(&inode->i_mutex);
1914 if (IS_SWAPFILE(inode)) { 1913 if (IS_SWAPFILE(inode))
1915 error = -EBUSY; 1914 return -EBUSY;
1916 goto bad_swap; 1915 } else
1917 } 1916 return -EINVAL;
1918 } else {
1919 error = -EINVAL;
1920 goto bad_swap;
1921 }
1922 1917
1923 return 0; 1918 return 0;
1924
1925bad_swap:
1926 return error;
1927} 1919}
1928 1920
1929SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) 1921SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)