[PATCH -mm] swsusp: userland interface fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

This patch contains some minor fixes of the swsusp userland interface:
1) use atomic_add_unless() instead of atomic_dec_and_test()/atomic_inc(),
2) remove a (unnecessary) memory barrier,
3) drop (unnecessary) access_ok() (actually the page will get released when
	the device is closed, so we don't need to worry if put_user() fails).

Please consider for applying.

Greetings,
Rafael


Signed-off-by: Rafael J. Wysocki <[email protected]>

 kernel/power/user.c |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)

Index: linux-2.6.16-rc1-mm3/kernel/power/user.c
===================================================================
--- linux-2.6.16-rc1-mm3.orig/kernel/power/user.c	2006-01-25 21:21:13.000000000 +0100
+++ linux-2.6.16-rc1-mm3/kernel/power/user.c	2006-01-25 21:53:52.000000000 +0100
@@ -40,10 +40,8 @@ static int snapshot_open(struct inode *i
 {
 	struct snapshot_data *data;
 
-	if (!atomic_dec_and_test(&device_available)) {
-		atomic_inc(&device_available);
+	if (!atomic_add_unless(&device_available, -1, 0))
 		return -EBUSY;
-	}
 
 	if ((filp->f_flags & O_ACCMODE) == O_RDWR)
 		return -ENOSYS;
@@ -198,7 +196,6 @@ static int snapshot_ioctl(struct inode *
 		pm_prepare_console();
 		error = device_suspend(PMSG_FREEZE);
 		if (!error) {
-			mb();
 			error = swsusp_resume();
 			device_resume();
 		}
@@ -223,10 +220,6 @@ static int snapshot_ioctl(struct inode *
 		break;
 
 	case SNAPSHOT_GET_SWAP_PAGE:
-		if (!access_ok(VERIFY_WRITE, (unsigned long __user *)arg, _IOC_SIZE(cmd))) {
-			error = -EINVAL;
-			break;
-		}
 		if (data->swap < 0 || data->swap >= MAX_SWAPFILES) {
 			error = -ENODEV;
 			break;
@@ -241,7 +234,7 @@ static int snapshot_ioctl(struct inode *
 		offset = alloc_swap_page(data->swap, data->bitmap);
 		if (offset) {
 			offset <<= PAGE_SHIFT;
-			__put_user(offset, (loff_t __user *)arg);
+			error = put_user(offset, (loff_t __user *)arg);
 		} else {
 			error = -ENOSPC;
 		}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux