From 0f22f2b357b06208fc7c0b82ce3f0929d00877ca Mon Sep 17 00:00:00 2001
From: Colin Cross <ccross@android.com>
Date: Mon, 22 Jul 2013 16:53:15 -0700
Subject: [PATCH] power: set PF_NOFREEZE flag on SNAPSHOT_FREEZE task

The task that calls the SNAPSHOT_FREEZE ioctl needs to return back
to userspace and continue preparing a suspend-to-disk image. Set
the PF_NOFREEZE flag on it so that it doesn't accidentally freeze
if it comes across a call to try_to_freeze().

Reported-by: Michael Leun <lkml20130126@newton.leun.net>
Signed-off-by: Colin Cross <ccross@android.com>
---
 kernel/power/user.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/power/user.c b/kernel/power/user.c
index 4ed81e7..17f9c20 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -219,6 +219,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
 		sys_sync();
 		printk("done.\n");
 
+		current->flags |= PF_NOFREEZE;
 		error = freeze_processes();
 		if (!error)
 			data->frozen = 1;
@@ -229,6 +230,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
 			break;
 		pm_restore_gfp_mask();
 		thaw_processes();
+		current->flags &= ~PF_NOFREEZE;
 		data->frozen = 0;
 		break;
 
-- 
1.8.3

