Skip to content

Commit 11a33de

Browse files
GustavoARSilvadavem330
authored andcommitted
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>
1 parent 1075a47 commit 11a33de

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎net/sched/sch_taprio.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,11 +1108,10 @@ static void setup_txtime(struct taprio_sched *q,
11081108

11091109
static struct tc_taprio_qopt_offload *taprio_offload_alloc(int num_entries)
11101110
{
1111-
size_t size = sizeof(struct tc_taprio_sched_entry) * num_entries +
1112-
sizeof(struct __tc_taprio_qopt_offload);
11131111
struct __tc_taprio_qopt_offload *__offload;
11141112

1115-
__offload = kzalloc(size, GFP_KERNEL);
1113+
__offload = kzalloc(struct_size(__offload, offload.entries, num_entries),
1114+
GFP_KERNEL);
11161115
if (!__offload)
11171116
return NULL;
11181117

0 commit comments

Comments
 (0)