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 4648f12..c00cca3 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;