Skip to contentSkip to conversation

netfilter: nf_tables: use kzalloc for hook allocation

PATCH New Florian Westphal 1 participant 1 message Feb 21, 2024

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nf_tables: use kzalloc for hook allocation

KMSAN reports unitialized variable when registering the hook,
reg->hook_ops_type == NF_HOOK_OP_BPF)

        ~~~~~~~~~~~ undefined

This is a small structure, just use kzalloc to make sure this won't happen again when new fields get added to nf_hook_ops.

Fixes 7b4b2fa37587 ("netfilter: annotate nf_tables base hook ops")
---
 net/netfilter/nf_tables_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
index f8e3f70c35bd..e61271a5db1a 100644
@@ -2080,7 +2080,7 @@ static struct nft_hook *nft_netdev_hook_alloc(struct net *net,
 	struct nft_hook *hook;
 	int err;
 
-	hook = kmalloc(sizeof(struct nft_hook), GFP_KERNEL_ACCOUNT);
+	hook = kzalloc(sizeof(struct nft_hook), GFP_KERNEL_ACCOUNT);
 	if (!hook) {
 		err = -ENOMEM;
 		goto err_hook_alloc;
Signature · 1 line
2.43.0