Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mwl8k: use kcalloc instead of kmalloc & memset

Use kcalloc or kzalloc rather than the combination of kmalloc and memset.

Thanks coccicheck for detecting this.
(http://coccinelle.lip6.fr/)

Signed-off-by: Shan Wei <shanwei@cn.fujitsu.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Shan Wei and committed by
John W. Linville
b9ede5f1 d07bfd8b

+2 -4
+2 -4
drivers/net/wireless/mwl8k.c
··· 1056 1056 } 1057 1057 memset(rxq->rxd, 0, size); 1058 1058 1059 - rxq->buf = kmalloc(MWL8K_RX_DESCS * sizeof(*rxq->buf), GFP_KERNEL); 1059 + rxq->buf = kcalloc(MWL8K_RX_DESCS, sizeof(*rxq->buf), GFP_KERNEL); 1060 1060 if (rxq->buf == NULL) { 1061 1061 wiphy_err(hw->wiphy, "failed to alloc RX skbuff list\n"); 1062 1062 pci_free_consistent(priv->pdev, size, rxq->rxd, rxq->rxd_dma); 1063 1063 return -ENOMEM; 1064 1064 } 1065 - memset(rxq->buf, 0, MWL8K_RX_DESCS * sizeof(*rxq->buf)); 1066 1065 1067 1066 for (i = 0; i < MWL8K_RX_DESCS; i++) { 1068 1067 int desc_size; ··· 1346 1347 } 1347 1348 memset(txq->txd, 0, size); 1348 1349 1349 - txq->skb = kmalloc(MWL8K_TX_DESCS * sizeof(*txq->skb), GFP_KERNEL); 1350 + txq->skb = kcalloc(MWL8K_TX_DESCS, sizeof(*txq->skb), GFP_KERNEL); 1350 1351 if (txq->skb == NULL) { 1351 1352 wiphy_err(hw->wiphy, "failed to alloc TX skbuff list\n"); 1352 1353 pci_free_consistent(priv->pdev, size, txq->txd, txq->txd_dma); 1353 1354 return -ENOMEM; 1354 1355 } 1355 - memset(txq->skb, 0, MWL8K_TX_DESCS * sizeof(*txq->skb)); 1356 1356 1357 1357 for (i = 0; i < MWL8K_TX_DESCS; i++) { 1358 1358 struct mwl8k_tx_desc *tx_desc;