summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireguard/selftest/counter.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-05-25 08:55:12 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-05-25 08:55:12 +0200
commitf7d8f3f092d001f8d91552d2697643e727694942 (patch)
tree0dfa61cc5b94eef94dfbaf1efdc362385792d0f2 /drivers/net/wireguard/selftest/counter.c
parentdriver core: Remove unnecessary is_fwnode_dev variable in device_add() (diff)
parentLinux 5.7-rc7 (diff)
downloadlinux-f7d8f3f092d001f8d91552d2697643e727694942.tar.xz
linux-f7d8f3f092d001f8d91552d2697643e727694942.zip
Merge 5.7-rc7 into driver-core-next
We need the driver core fixes in here as well Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net/wireguard/selftest/counter.c')
-rw-r--r--drivers/net/wireguard/selftest/counter.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/net/wireguard/selftest/counter.c b/drivers/net/wireguard/selftest/counter.c
index f4fbb9072ed7..ec3c156bf91b 100644
--- a/drivers/net/wireguard/selftest/counter.c
+++ b/drivers/net/wireguard/selftest/counter.c
@@ -6,18 +6,24 @@
#ifdef DEBUG
bool __init wg_packet_counter_selftest(void)
{
+ struct noise_replay_counter *counter;
unsigned int test_num = 0, i;
- union noise_counter counter;
bool success = true;
-#define T_INIT do { \
- memset(&counter, 0, sizeof(union noise_counter)); \
- spin_lock_init(&counter.receive.lock); \
+ counter = kmalloc(sizeof(*counter), GFP_KERNEL);
+ if (unlikely(!counter)) {
+ pr_err("nonce counter self-test malloc: FAIL\n");
+ return false;
+ }
+
+#define T_INIT do { \
+ memset(counter, 0, sizeof(*counter)); \
+ spin_lock_init(&counter->lock); \
} while (0)
#define T_LIM (COUNTER_WINDOW_SIZE + 1)
#define T(n, v) do { \
++test_num; \
- if (counter_validate(&counter, n) != (v)) { \
+ if (counter_validate(counter, n) != (v)) { \
pr_err("nonce counter self-test %u: FAIL\n", \
test_num); \
success = false; \
@@ -99,6 +105,7 @@ bool __init wg_packet_counter_selftest(void)
if (success)
pr_info("nonce counter self-tests: pass\n");
+ kfree(counter);
return success;
}
#endif