Skip to content

Commit

Permalink
net: pktgen: fix race between pktgen_thread_worker() and kthread_stop()
Browse files Browse the repository at this point in the history
pktgen_thread_worker() is obviously racy, kthread_stop() can come
between the kthread_should_stop() check and set_current_state().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Jan Stancek <jstancek@redhat.com>
Reported-by: Marcelo Leitner <mleitner@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Oleg Nesterov authored and David S. Miller committed Jul 9, 2015
1 parent 4a0e3e9 commit fecdf8b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/core/pktgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -3572,8 +3572,10 @@ static int pktgen_thread_worker(void *arg)
pktgen_rem_thread(t);

/* Wait for kthread_stop */
while (!kthread_should_stop()) {
for (;;) {
set_current_state(TASK_INTERRUPTIBLE);
if (kthread_should_stop())
break;
schedule();
}
__set_current_state(TASK_RUNNING);
Expand Down

0 comments on commit fecdf8b

Please sign in to comment.