diff options
author | Yan Zhen <yanzhen@vivo.com> | 2024-08-26 11:41:36 +0800 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2024-09-03 10:47:16 +0200 |
commit | 20eb5e7cb78c331107fbdf2f77a30fbea9338638 (patch) | |
tree | c9c5e91d7af09fa0663cce4b85595b93f64c7d4d /net/bridge | |
parent | 4a1d3acd6ea86075e77fcc1188c3fc372833ba73 (diff) | |
download | lwn-20eb5e7cb78c331107fbdf2f77a30fbea9338638.tar.gz lwn-20eb5e7cb78c331107fbdf2f77a30fbea9338638.zip |
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/bridge')
-rw-r--r-- | net/bridge/netfilter/ebtables.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index cbd0e3586c3f..3e67d4aff419 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -1256,7 +1256,7 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table, goto free_unlock; } - ops = kmemdup(template_ops, sizeof(*ops) * num_ops, GFP_KERNEL); + ops = kmemdup_array(template_ops, num_ops, sizeof(*ops), GFP_KERNEL); if (!ops) { ret = -ENOMEM; if (newinfo->nentries) |