Skip to content

Commit 4e3fd72

Browse files
GustavoARSilvakuba-moo
authored andcommitted
wireguard: ratelimiter: use kvcalloc() instead of kvzalloc()
Use 2-factor argument form kvcalloc() instead of kvzalloc(). Link: KSPP#162 Fixes: e7096c1 ("net: WireGuard secure network tunnel") Signed-off-by: Gustavo A. R. Silva <[email protected]> [Jason: Gustavo's link above is for KSPP, but this isn't actually a security fix, as table_size is bounded to 8192 anyway, and gcc realizes this, so the codegen comes out to be about the same.] Signed-off-by: Jason A. Donenfeld <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fb32f4f commit 4e3fd72

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/wireguard/ratelimiter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ int wg_ratelimiter_init(void)
176176
(1U << 14) / sizeof(struct hlist_head)));
177177
max_entries = table_size * 8;
178178

179-
table_v4 = kvzalloc(table_size * sizeof(*table_v4), GFP_KERNEL);
179+
table_v4 = kvcalloc(table_size, sizeof(*table_v4), GFP_KERNEL);
180180
if (unlikely(!table_v4))
181181
goto err_kmemcache;
182182

183183
#if IS_ENABLED(CONFIG_IPV6)
184-
table_v6 = kvzalloc(table_size * sizeof(*table_v6), GFP_KERNEL);
184+
table_v6 = kvcalloc(table_size, sizeof(*table_v6), GFP_KERNEL);
185185
if (unlikely(!table_v6)) {
186186
kvfree(table_v4);
187187
goto err_kmemcache;

0 commit comments

Comments
 (0)