Browse Source

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>
Shan Wei 14 năm trước cách đây
mục cha
commit
b9ede5f1dc
1 tập tin đã thay đổi với 2 bổ sung4 xóa
  1. 2 4
      drivers/net/wireless/mwl8k.c

+ 2 - 4
drivers/net/wireless/mwl8k.c

@@ -1056,13 +1056,12 @@ static int mwl8k_rxq_init(struct ieee80211_hw *hw, int index)
 	}
 	}
 	memset(rxq->rxd, 0, size);
 	memset(rxq->rxd, 0, size);
 
 
-	rxq->buf = kmalloc(MWL8K_RX_DESCS * sizeof(*rxq->buf), GFP_KERNEL);
+	rxq->buf = kcalloc(MWL8K_RX_DESCS, sizeof(*rxq->buf), GFP_KERNEL);
 	if (rxq->buf == NULL) {
 	if (rxq->buf == NULL) {
 		wiphy_err(hw->wiphy, "failed to alloc RX skbuff list\n");
 		wiphy_err(hw->wiphy, "failed to alloc RX skbuff list\n");
 		pci_free_consistent(priv->pdev, size, rxq->rxd, rxq->rxd_dma);
 		pci_free_consistent(priv->pdev, size, rxq->rxd, rxq->rxd_dma);
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
-	memset(rxq->buf, 0, MWL8K_RX_DESCS * sizeof(*rxq->buf));
 
 
 	for (i = 0; i < MWL8K_RX_DESCS; i++) {
 	for (i = 0; i < MWL8K_RX_DESCS; i++) {
 		int desc_size;
 		int desc_size;
@@ -1347,13 +1346,12 @@ static int mwl8k_txq_init(struct ieee80211_hw *hw, int index)
 	}
 	}
 	memset(txq->txd, 0, size);
 	memset(txq->txd, 0, size);
 
 
-	txq->skb = kmalloc(MWL8K_TX_DESCS * sizeof(*txq->skb), GFP_KERNEL);
+	txq->skb = kcalloc(MWL8K_TX_DESCS, sizeof(*txq->skb), GFP_KERNEL);
 	if (txq->skb == NULL) {
 	if (txq->skb == NULL) {
 		wiphy_err(hw->wiphy, "failed to alloc TX skbuff list\n");
 		wiphy_err(hw->wiphy, "failed to alloc TX skbuff list\n");
 		pci_free_consistent(priv->pdev, size, txq->txd, txq->txd_dma);
 		pci_free_consistent(priv->pdev, size, txq->txd, txq->txd_dma);
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
-	memset(txq->skb, 0, MWL8K_TX_DESCS * sizeof(*txq->skb));
 
 
 	for (i = 0; i < MWL8K_TX_DESCS; i++) {
 	for (i = 0; i < MWL8K_TX_DESCS; i++) {
 		struct mwl8k_tx_desc *tx_desc;
 		struct mwl8k_tx_desc *tx_desc;