]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
pktgen: fix module unload for good
authorEric Dumazet <edumazet@google.com>
Thu, 17 May 2012 23:52:26 +0000 (23:52 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 9 Jun 2012 15:33:03 +0000 (00:33 +0900)
[ Upstream commit d4b1133558e0d417342d5d2c49e4c35b428ff20d ]

commit c57b5468406 (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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/pktgen.c

index 0865ea025c929a59f7c90054e29f4a1cc09f7343..c0e0f7679e75838833b1ea9be807600ae4d3cbbc 100644 (file)
@@ -3755,13 +3755,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) {