diff options
author | Gustavo A. R. Silva | 2020-06-18 09:53:42 -0500 |
---|---|---|
committer | David S. Miller | 2020-06-19 20:19:24 -0700 |
commit | c5eb179edd8a169949b1fb153ecfd04649a71c8d (patch) | |
tree | 81caa2b64f40066395f5a27f6560b2c03ff656f3 /net | |
parent | 11a33de2df06b4ed23844181cb5c03eea67bfed1 (diff) |
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/sched/cls_u32.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index e15ff335953d..771b068f8254 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -796,9 +796,7 @@ static struct tc_u_knode *u32_init_knode(struct net *net, struct tcf_proto *tp, struct tc_u32_sel *s = &n->sel; struct tc_u_knode *new; - new = kzalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key), - GFP_KERNEL); - + new = kzalloc(struct_size(new, sel.keys, s->nkeys), GFP_KERNEL); if (!new) return NULL; |