From 4a10e55f47e4e9310d968f3756a0b66dc65158c9 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 4 Sep 2018 11:18:09 -0600 Subject: global: always find OOM unlikely Suggested-by: Sultan Alsawaf Signed-off-by: Jason A. Donenfeld --- src/selftest/allowedips.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/selftest/allowedips.h') diff --git a/src/selftest/allowedips.h b/src/selftest/allowedips.h index 6b47fc8..83cfb34 100644 --- a/src/selftest/allowedips.h +++ b/src/selftest/allowedips.h @@ -178,7 +178,7 @@ horrible_allowedips_insert_v4(struct horrible_allowedips *table, { struct horrible_allowedips_node *node = kzalloc(sizeof(*node), GFP_KERNEL); - if (!node) + if (unlikely(!node)) return -ENOMEM; node->ip.in = *ip; node->mask = horrible_cidr_to_mask(cidr); @@ -194,7 +194,7 @@ horrible_allowedips_insert_v6(struct horrible_allowedips *table, { struct horrible_allowedips_node *node = kzalloc(sizeof(*node), GFP_KERNEL); - if (!node) + if (unlikely(!node)) return -ENOMEM; node->ip.in6 = *ip; node->mask = horrible_cidr_to_mask(cidr); @@ -255,13 +255,13 @@ static __init bool randomized_test(void) horrible_allowedips_init(&h); peers = kcalloc(NUM_PEERS, sizeof(*peers), GFP_KERNEL); - if (!peers) { + if (unlikely(!peers)) { pr_info("allowedips random self-test: out of memory\n"); goto free; } for (i = 0; i < NUM_PEERS; ++i) { peers[i] = kzalloc(sizeof(*peers[i]), GFP_KERNEL); - if (!peers[i]) { + if (unlikely(!peers[i])) { pr_info("allowedips random self-test: out of memory\n"); goto free; } @@ -455,7 +455,7 @@ static __init int walk_callback(void *ctx, const u8 *ip, u8 cidr, int family) #define init_peer(name) do { \ name = kzalloc(sizeof(*name), GFP_KERNEL); \ - if (!name) { \ + if (unlikely(!name)) { \ pr_info("allowedips self-test: out of memory\n"); \ goto free; \ } \ -- cgit v1.2.3