net: wireguard: Use kvcalloc() instead of kvzalloc()
Subsystems (3)
PATCH 1/1 net: wireguard: Use kvcalloc() instead of kvzalloc()
Use 2-factor argument form kvcalloc() instead of kvzalloc().
--- drivers/net/wireguard/ratelimiter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireguard/ratelimiter.c +2 -2
@@ -176,12 +176,12 @@ int wg_ratelimiter_init(void) (1U << 14) / sizeof(struct hlist_head))); max_entries = table_size *8 ; - table_v4 =kvzalloc (table_size *sizeof (*table_v4),GFP_KERNEL ); + table_v4 =kvcalloc (table_size,sizeof (*table_v4),GFP_KERNEL );if (unlikely (!table_v4)) goto err_kmemcache;#if IS_ENABLED (CONFIG_IPV6 ) - table_v6 =kvzalloc (table_size *sizeof (*table_v6),GFP_KERNEL ); + table_v6 =kvcalloc (table_size,sizeof (*table_v6),GFP_KERNEL );if (unlikely (!table_v6)) {kvfree (table_v4); goto err_kmemcache;
Signature · 1 line
2.27.0
Jason A. Donenfeld
maintainerHi Gustavo,
table_size never exceeds 8192, so there's really not an issue with integer overflow here. However, I checked the codegen of before/after this patch, and it looks like gcc realizes this too, and so elides them to be basically the same. So I'll apply this to the wireguard-linux tree. Thanks for the patch.
Jason