]> git.itanic.dy.fi Git - linux-stable/commitdiff
netfilter: nf_tables: use kzalloc for hook allocation
authorFlorian Westphal <fw@strlen.de>
Wed, 21 Feb 2024 17:38:45 +0000 (18:38 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 21 Feb 2024 23:15:58 +0000 (00:15 +0100)
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")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index 485e047d5f98b08aa1cc484c47a5b7e00eb99881..7e938c7397dda5416d16ab9312f5f9876afeca79 100644 (file)
@@ -2082,7 +2082,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;