net: dsa: replace count*size kmalloc by kmalloc_array
authorFabian Frederick <fabf@skynet.be>
Fri, 14 Nov 2014 18:36:42 +0000 (19:36 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 16 Nov 2014 19:41:39 +0000 (14:41 -0500)
kmalloc_array manages count*sizeof overflow.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/dsa.c

index 4648f12098ad6490f44f2446c4a9c67323e2fbef..c00cca3e1913a640aba050e45eb449d4dd246c9c 100644 (file)
@@ -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;