Skip to content

Commit 3c14c4b

Browse files
committed
allowedips: initialize list head in selftest
The randomized trie tests weren't initializing the dummy peer list head, resulting in a NULL pointer dereference when used. Fix this by initializing it in the randomized trie test, just like we do for the static unit test. While we're at it, all of the other strings like this have the word "self-test", so add it to the missing place here. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
1 parent 4d8b7ed commit 3c14c4b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/selftest/allowedips.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ static __init bool randomized_test(void)
296296
goto free;
297297
}
298298
kref_init(&peers[i]->refcount);
299+
INIT_LIST_HEAD(&peers[i]->allowedips_list);
299300
}
300301

301302
mutex_lock(&mutex);
@@ -333,7 +334,7 @@ static __init bool randomized_test(void)
333334
if (wg_allowedips_insert_v4(&t,
334335
(struct in_addr *)mutated,
335336
cidr, peer, &mutex) < 0) {
336-
pr_err("allowedips random malloc: FAIL\n");
337+
pr_err("allowedips random self-test malloc: FAIL\n");
337338
goto free_locked;
338339
}
339340
if (horrible_allowedips_insert_v4(&h,

0 commit comments

Comments
 (0)