]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/freezer.h
freezer: close potential race between refrigerator and thaw_tasks
[linux-2.6-omap-h63xx.git] / include / linux / freezer.h
index 5e75e26d4787248caf175063afad75010824672a..db5423eae24d8dd511bbd88714b5264b45b4ba19 100644 (file)
@@ -37,14 +37,24 @@ static inline void do_not_freeze(struct task_struct *p)
 
 /*
  * Wake up a frozen process
+ *
+ * task_lock() is taken to prevent the race with refrigerator() which may
+ * occur if the freezing of tasks fails.  Namely, without the lock, if the
+ * freezing of tasks failed, thaw_tasks() might have run before a task in
+ * refrigerator() could call frozen_process(), in which case the task would be
+ * frozen and no one would thaw it.
  */
 static inline int thaw_process(struct task_struct *p)
 {
+       task_lock(p);
        if (frozen(p)) {
                p->flags &= ~PF_FROZEN;
+               task_unlock(p);
                wake_up_process(p);
                return 1;
        }
+       clear_tsk_thread_flag(p, TIF_FREEZE);
+       task_unlock(p);
        return 0;
 }