aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/ratelimiter.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-04 11:18:09 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-04 11:18:58 -0600
commit32d43304abbe9a8546a0c453b7f358a359e4467a (patch)
treeab42a47a8ecd2fae1d8ed64c5bc2479ac8d7161f /src/ratelimiter.c
parentglobal: prefer sizeof(*pointer) when possible (diff)
downloadwireguard-monolithic-historical-32d43304abbe9a8546a0c453b7f358a359e4467a.tar.xz
wireguard-monolithic-historical-32d43304abbe9a8546a0c453b7f358a359e4467a.zip
global: always find OOM unlikely
Suggested-by: Sultan Alsawaf <sultanxda@gmail.com>
Diffstat (limited to 'src/ratelimiter.c')
-rw-r--r--src/ratelimiter.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ratelimiter.c b/src/ratelimiter.c
index 6c7262a..52381ee 100644
--- a/src/ratelimiter.c
+++ b/src/ratelimiter.c
@@ -133,7 +133,7 @@ bool ratelimiter_allow(struct sk_buff *skb, struct net *net)
goto err_oom;
entry = kmem_cache_alloc(entry_cache, GFP_KERNEL);
- if (!entry)
+ if (unlikely(!entry))
goto err_oom;
entry->net = net;
@@ -174,12 +174,12 @@ int ratelimiter_init(void)
max_entries = table_size * 8;
table_v4 = kvzalloc(table_size * sizeof(*table_v4), GFP_KERNEL);
- if (!table_v4)
+ if (unlikely(!table_v4))
goto err_kmemcache;
#if IS_ENABLED(CONFIG_IPV6)
table_v6 = kvzalloc(table_size * sizeof(*table_v6), GFP_KERNEL);
- if (!table_v6) {
+ if (unlikely(!table_v6)) {
kvfree(table_v4);
goto err_kmemcache;
}