소스 검색

pktgen: fix module unload for good

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>
Eric Dumazet 13 년 전
부모
커밋
d4b1133558
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      net/core/pktgen.c

+ 2 - 2
net/core/pktgen.c

@@ -3755,13 +3755,13 @@ static void __exit pg_cleanup(void)
 {
 {
 	struct pktgen_thread *t;
 	struct pktgen_thread *t;
 	struct list_head *q, *n;
 	struct list_head *q, *n;
-	struct list_head list;
+	LIST_HEAD(list);
 
 
 	/* Stop all interfaces & threads */
 	/* Stop all interfaces & threads */
 	pktgen_exiting = true;
 	pktgen_exiting = true;
 
 
 	mutex_lock(&pktgen_thread_lock);
 	mutex_lock(&pktgen_thread_lock);
-	list_splice(&list, &pktgen_threads);
+	list_splice_init(&pktgen_threads, &list);
 	mutex_unlock(&pktgen_thread_lock);
 	mutex_unlock(&pktgen_thread_lock);
 
 
 	list_for_each_safe(q, n, &list) {
 	list_for_each_safe(q, n, &list) {