Skip to content

Commit

Permalink
net: dsa: replace count*size kmalloc by kmalloc_array
Browse files Browse the repository at this point in the history
kmalloc_array manages count*sizeof overflow.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Fabian Frederick authored and davem330 committed Nov 16, 2014
1 parent f35423c commit 5bc4b46
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/dsa/dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,8 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,

/* First time routing table allocation */
if (!cd->rtable) {
cd->rtable = kmalloc(pd->nr_chips * sizeof(s8), GFP_KERNEL);
cd->rtable = kmalloc_array(pd->nr_chips, sizeof(s8),
GFP_KERNEL);
if (!cd->rtable)
return -ENOMEM;

Expand Down

0 comments on commit 5bc4b46

Please sign in to comment.