Skip to content

Commit

Permalink
stop_machine: fix race with return value (fixes Bug #11989)
Browse files Browse the repository at this point in the history
Bug #11989: Suspend failure on NForce4-based boards due to chanes in
stop_machine

We should not access active.fnret outside the lock; in theory the next
stop_machine could overwrite it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Tested-by: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Rusty Russell authored and Linus Torvalds committed Nov 16, 2008
1 parent 5c06fe7 commit e14c8bf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kernel/stop_machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static int chill(void *unused)
int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus)
{
struct work_struct *sm_work;
int i;
int i, ret;

/* Set up initial state. */
mutex_lock(&lock);
Expand All @@ -137,8 +137,9 @@ int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus)
/* This will release the thread on our CPU. */
put_cpu();
flush_workqueue(stop_machine_wq);
ret = active.fnret;
mutex_unlock(&lock);
return active.fnret;
return ret;
}

int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus)
Expand Down

0 comments on commit e14c8bf

Please sign in to comment.