Skip to content

Commit

Permalink
pktgen: fix module unload for good
Browse files Browse the repository at this point in the history
commit d4b1133 upstream.

commit c57b546 (pktgen: fix crash at module unload) did a very poor
job with list primitives.

1) list_splice() arguments were in the wrong order

2) list_splice(list, head) has undefined behavior if head is not
initialized.

3) We should use the list_splice_init() variant to clear pktgen_threads
list.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
  • Loading branch information
Eric Dumazet authored and bwhacks committed May 20, 2012
1 parent 03f3b84 commit ef6bdf3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/core/pktgen.c
Expand Up @@ -3758,13 +3758,13 @@ static void __exit pg_cleanup(void)
{
struct pktgen_thread *t;
struct list_head *q, *n;
struct list_head list;
LIST_HEAD(list);

/* Stop all interfaces & threads */
pktgen_exiting = true;

mutex_lock(&pktgen_thread_lock);
list_splice(&list, &pktgen_threads);
list_splice_init(&pktgen_threads, &list);
mutex_unlock(&pktgen_thread_lock);

list_for_each_safe(q, n, &list) {
Expand Down

0 comments on commit ef6bdf3

Please sign in to comment.