Commit a2a0ffb0 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Florian Westphal

netfilter: nft_set_pipapo: Use struct_size()

Use struct_size() instead of hand writing it.
This is less verbose and more informative.
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
parent 61e03e91
...@@ -1274,8 +1274,7 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old) ...@@ -1274,8 +1274,7 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
struct nft_pipapo_match *new; struct nft_pipapo_match *new;
int i; int i;
new = kmalloc(sizeof(*new) + sizeof(*dst) * old->field_count, new = kmalloc(struct_size(new, f, old->field_count), GFP_KERNEL);
GFP_KERNEL);
if (!new) if (!new)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -2059,8 +2058,7 @@ static int nft_pipapo_init(const struct nft_set *set, ...@@ -2059,8 +2058,7 @@ static int nft_pipapo_init(const struct nft_set *set,
if (field_count > NFT_PIPAPO_MAX_FIELDS) if (field_count > NFT_PIPAPO_MAX_FIELDS)
return -EINVAL; return -EINVAL;
m = kmalloc(sizeof(*priv->match) + sizeof(*f) * field_count, m = kmalloc(struct_size(m, f, field_count), GFP_KERNEL);
GFP_KERNEL);
if (!m) if (!m)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment