Skip to content

Commit a2a0ffb

Browse files
tititiou36Florian Westphal
authored and
Florian Westphal
committed
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: Christophe JAILLET <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Florian Westphal <[email protected]>
1 parent 61e03e9 commit a2a0ffb

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

net/netfilter/nft_set_pipapo.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,8 +1274,7 @@ static struct nft_pipapo_match *pipapo_clone(struct nft_pipapo_match *old)
12741274
struct nft_pipapo_match *new;
12751275
int i;
12761276

1277-
new = kmalloc(sizeof(*new) + sizeof(*dst) * old->field_count,
1278-
GFP_KERNEL);
1277+
new = kmalloc(struct_size(new, f, old->field_count), GFP_KERNEL);
12791278
if (!new)
12801279
return ERR_PTR(-ENOMEM);
12811280

@@ -2059,8 +2058,7 @@ static int nft_pipapo_init(const struct nft_set *set,
20592058
if (field_count > NFT_PIPAPO_MAX_FIELDS)
20602059
return -EINVAL;
20612060

2062-
m = kmalloc(sizeof(*priv->match) + sizeof(*f) * field_count,
2063-
GFP_KERNEL);
2061+
m = kmalloc(struct_size(m, f, field_count), GFP_KERNEL);
20642062
if (!m)
20652063
return -ENOMEM;
20662064

0 commit comments

Comments
 (0)