Skip to content

Commit fc5778c

Browse files
committed
Merge branch 'pktgen-races'
Oleg Nesterov says: ==================== net: pktgen: fix race between pktgen_thread_worker() and kthread_stop() I am not familiar with this code and I have no idea how to test these changes, so 2/2 comes as a separate change. 1/2 looks like the obvious bugfix, and probably candidate for -stable. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 4a0e3e9 + 1fbe4b4 commit fc5778c

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

net/core/pktgen.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3571,13 +3571,6 @@ static int pktgen_thread_worker(void *arg)
35713571
pr_debug("%s removing thread\n", t->tsk->comm);
35723572
pktgen_rem_thread(t);
35733573

3574-
/* Wait for kthread_stop */
3575-
while (!kthread_should_stop()) {
3576-
set_current_state(TASK_INTERRUPTIBLE);
3577-
schedule();
3578-
}
3579-
__set_current_state(TASK_RUNNING);
3580-
35813574
return 0;
35823575
}
35833576

@@ -3769,6 +3762,7 @@ static int __net_init pktgen_create_thread(int cpu, struct pktgen_net *pn)
37693762
}
37703763

37713764
t->net = pn;
3765+
get_task_struct(p);
37723766
wake_up_process(p);
37733767
wait_for_completion(&t->start_done);
37743768

@@ -3891,6 +3885,7 @@ static void __net_exit pg_net_exit(struct net *net)
38913885
t = list_entry(q, struct pktgen_thread, th_list);
38923886
list_del(&t->th_list);
38933887
kthread_stop(t->tsk);
3888+
put_task_struct(t->tsk);
38943889
kfree(t);
38953890
}
38963891

0 commit comments

Comments
 (0)