diff options
author | Gustavo A. R. Silva <gustavoars@kernel.org> | 2020-06-18 16:46:48 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-06-20 05:18:43 +0200 |
commit | 11a33de2df06b4ed23844181cb5c03eea67bfed1 (patch) | |
tree | 3a1c88b2dd235be33b24842c1d9569401e5ac9dd | |
parent | Merge branch 'Clause-45-PHY-probing-improvements' (diff) | |
download | linux-11a33de2df06b4ed23844181cb5c03eea67bfed1.tar.xz linux-11a33de2df06b4ed23844181cb5c03eea67bfed1.zip |
taprio: 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. Also, remove unnecessary
variable _size_.
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>
-rw-r--r-- | net/sched/sch_taprio.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index b1eb12d33b9a..e981992634dd 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1108,11 +1108,10 @@ static void setup_txtime(struct taprio_sched *q, static struct tc_taprio_qopt_offload *taprio_offload_alloc(int num_entries) { - size_t size = sizeof(struct tc_taprio_sched_entry) * num_entries + - sizeof(struct __tc_taprio_qopt_offload); struct __tc_taprio_qopt_offload *__offload; - __offload = kzalloc(size, GFP_KERNEL); + __offload = kzalloc(struct_size(__offload, offload.entries, num_entries), + GFP_KERNEL); if (!__offload) return NULL; |