diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-11-25 11:16:01 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-11-26 11:33:33 +0100 |
commit | da0e24a44cfc76a93a369075c2514a4b3247c840 (patch) | |
tree | aec0bc869928d3700f4a7ce60674c3a5c979aa08 | |
parent | c2b7c2d77b6b26f8613018605b50c4ccb83c7e85 (diff) |
allowedips: avoid double lock in selftest error case
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | src/selftest/allowedips.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/selftest/allowedips.c b/src/selftest/allowedips.c index 6e244a9..846db14 100644 --- a/src/selftest/allowedips.c +++ b/src/selftest/allowedips.c @@ -307,12 +307,12 @@ static __init bool randomized_test(void) if (wg_allowedips_insert_v4(&t, (struct in_addr *)ip, cidr, peer, &mutex) < 0) { pr_err("allowedips random self-test malloc: FAIL\n"); - goto free; + goto free_locked; } if (horrible_allowedips_insert_v4(&h, (struct in_addr *)ip, cidr, peer) < 0) { pr_err("allowedips random self-test malloc: FAIL\n"); - goto free; + goto free_locked; } for (j = 0; j < NUM_MUTATED_ROUTES; ++j) { memcpy(mutated, ip, 4); @@ -334,12 +334,12 @@ static __init bool randomized_test(void) (struct in_addr *)mutated, cidr, peer, &mutex) < 0) { pr_err("allowedips random malloc: FAIL\n"); - goto free; + goto free_locked; } if (horrible_allowedips_insert_v4(&h, (struct in_addr *)mutated, cidr, peer)) { pr_err("allowedips random self-test malloc: FAIL\n"); - goto free; + goto free_locked; } } } @@ -351,12 +351,12 @@ static __init bool randomized_test(void) if (wg_allowedips_insert_v6(&t, (struct in6_addr *)ip, cidr, peer, &mutex) < 0) { pr_err("allowedips random self-test malloc: FAIL\n"); - goto free; + goto free_locked; } if (horrible_allowedips_insert_v6(&h, (struct in6_addr *)ip, cidr, peer) < 0) { pr_err("allowedips random self-test malloc: FAIL\n"); - goto free; + goto free_locked; } for (j = 0; j < NUM_MUTATED_ROUTES; ++j) { memcpy(mutated, ip, 16); @@ -378,13 +378,13 @@ static __init bool randomized_test(void) (struct in6_addr *)mutated, cidr, peer, &mutex) < 0) { pr_err("allowedips random self-test malloc: FAIL\n"); - goto free; + goto free_locked; } if (horrible_allowedips_insert_v6( &h, (struct in6_addr *)mutated, cidr, peer)) { pr_err("allowedips random self-test malloc: FAIL\n"); - goto free; + goto free_locked; } } } @@ -417,6 +417,7 @@ static __init bool randomized_test(void) free: mutex_lock(&mutex); +free_locked: wg_allowedips_free(&t, &mutex); mutex_unlock(&mutex); horrible_allowedips_free(&h); |