patch-2.3.43 linux/mm/swapfile.c

Next file: linux/mm/vmscan.c
Previous file: linux/mm/slab.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.42/linux/mm/swapfile.c linux/mm/swapfile.c
@@ -445,12 +445,12 @@
 	struct swap_info_struct * p = NULL;
 	struct dentry * dentry;
 	int i, type, prev;
-	int err = -EPERM;
+	int err;
 	
-	lock_kernel();
 	if (!capable(CAP_SYS_ADMIN))
-		goto out;
+		return -EPERM;
 
+	lock_kernel();
 	dentry = namei(specialfile);
 	err = PTR_ERR(dentry);
 	if (IS_ERR(dentry))
@@ -587,7 +587,7 @@
 	struct dentry * swap_dentry;
 	unsigned int type;
 	int i, j, prev;
-	int error = -EPERM;
+	int error;
 	static int least_priority = 0;
 	union swap_header *swap_header = 0;
 	int swap_header_version;
@@ -596,13 +596,14 @@
 	int swapfilesize;
 	struct block_device *bdev = NULL;
 	
-	lock_kernel();
 	if (!capable(CAP_SYS_ADMIN))
-		goto out;
+		return -EPERM;
+	lock_kernel();
 	p = swap_info;
 	for (type = 0 ; type < nr_swapfiles ; type++,p++)
 		if (!(p->flags & SWP_USED))
 			break;
+	error = -EPERM;
 	if (type >= MAX_SWAPFILES)
 		goto out;
 	if (type >= nr_swapfiles)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)