Staging: rtl8192e: Use kcalloc instead of kzalloc to allocate array
authorShraddha Barke <shraddha.6596@gmail.com>
Fri, 9 Oct 2015 15:33:29 +0000 (21:03 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Oct 2015 03:54:14 +0000 (20:54 -0700)
The advantage of kcalloc is, that will prevent integer overflows which
could result from the multiplication of number of elements and size and
it is also a bit nicer to read.

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192e/rtllib_module.c

index a0d55466888d7aea3dedf11835594b4bee41cadf..113fbf7fbb17c9cdb7de6ca3d4a80cef09f3b2b8 100644 (file)
@@ -59,9 +59,8 @@ static inline int rtllib_networks_allocate(struct rtllib_device *ieee)
        if (ieee->networks)
                return 0;
 
-       ieee->networks = kzalloc(
-               MAX_NETWORK_COUNT * sizeof(struct rtllib_network),
-               GFP_KERNEL);
+       ieee->networks = kcalloc(MAX_NETWORK_COUNT,
+                                sizeof(struct rtllib_network), GFP_KERNEL);
        if (!ieee->networks)
                return -ENOMEM;