Skip to content

Commit

Permalink
allowedips: initialize list head in selftest
Browse files Browse the repository at this point in the history
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>
Change-Id: Id977cc2536b8b6e20ddcbd3f0bf723a1491adf53
(cherry picked from commit c20ed0b4bbc976b90cb3b0bf2ca3f3b4ff88df71)
Signed-off-by: TogoFire <togofire@mailfence.com>
  • Loading branch information
zx2c4 authored and TogoFire committed Jun 9, 2023
1 parent a6998bb commit b5cbffe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/wireguard/selftest/allowedips.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ static __init bool randomized_test(void)
goto free;
}
kref_init(&peers[i]->refcount);
INIT_LIST_HEAD(&peers[i]->allowedips_list);
}

mutex_lock(&mutex);
Expand Down Expand Up @@ -333,7 +334,7 @@ static __init bool randomized_test(void)
if (wg_allowedips_insert_v4(&t,
(struct in_addr *)mutated,
cidr, peer, &mutex) < 0) {
pr_err("allowedips random malloc: FAIL\n");
pr_err("allowedips random self-test malloc: FAIL\n");
goto free_locked;
}
if (horrible_allowedips_insert_v4(&h,
Expand Down

0 comments on commit b5cbffe

Please sign in to comment.