Skip to content

Commit fecdf8b

Browse files
oleg-nesterovdavem330
authored andcommitted
net: pktgen: fix race between pktgen_thread_worker() and kthread_stop()
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>
1 parent 4a0e3e9 commit fecdf8b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/core/pktgen.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3572,8 +3572,10 @@ static int pktgen_thread_worker(void *arg)
35723572
pktgen_rem_thread(t);
35733573

35743574
/* Wait for kthread_stop */
3575-
while (!kthread_should_stop()) {
3575+
for (;;) {
35763576
set_current_state(TASK_INTERRUPTIBLE);
3577+
if (kthread_should_stop())
3578+
break;
35773579
schedule();
35783580
}
35793581
__set_current_state(TASK_RUNNING);

0 commit comments

Comments
 (0)