summaryrefslogtreecommitdiff
path: root/net/netfilter
diff options
context:
space:
mode:
authorYan Zhen <yanzhen@vivo.com>2024-08-26 11:41:36 +0800
committerPablo Neira Ayuso <pablo@netfilter.org>2024-09-03 10:47:16 +0200
commit20eb5e7cb78c331107fbdf2f77a30fbea9338638 (patch)
treec9c5e91d7af09fa0663cce4b85595b93f64c7d4d /net/netfilter
parent4a1d3acd6ea86075e77fcc1188c3fc372833ba73 (diff)
netfilter: Use kmemdup_array instead of kmemdup for multiple allocation
When we are allocating an array, using kmemdup_array() to take care about multiplication and possible overflows. Also it makes auditing the code easier. Signed-off-by: Yan Zhen <yanzhen@vivo.com> Reviewed-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/nf_nat_core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index 016c816d91cb..6d8da6dddf99 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -1104,7 +1104,7 @@ int nf_nat_register_fn(struct net *net, u8 pf, const struct nf_hook_ops *ops,
if (!nat_proto_net->nat_hook_ops) {
WARN_ON(nat_proto_net->users != 0);
- nat_ops = kmemdup(orig_nat_ops, sizeof(*orig_nat_ops) * ops_count, GFP_KERNEL);
+ nat_ops = kmemdup_array(orig_nat_ops, ops_count, sizeof(*orig_nat_ops), GFP_KERNEL);
if (!nat_ops) {
mutex_unlock(&nf_nat_proto_mutex);
return -ENOMEM;