Skip to content

Commit c5eb179

Browse files
GustavoARSilvadavem330
authored andcommitted
net/sched: cls_u32: Use struct_size() in kzalloc()
Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. This code was detected with the help of Coccinelle and, audited and fixed manually. Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 11a33de commit c5eb179

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

‎net/sched/cls_u32.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,9 +796,7 @@ static struct tc_u_knode *u32_init_knode(struct net *net, struct tcf_proto *tp,
796796
struct tc_u32_sel *s = &n->sel;
797797
struct tc_u_knode *new;
798798

799-
new = kzalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key),
800-
GFP_KERNEL);
801-
799+
new = kzalloc(struct_size(new, sel.keys, s->nkeys), GFP_KERNEL);
802800
if (!new)
803801
return NULL;
804802

0 commit comments

Comments
 (0)