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

drivers/net: use vzalloc()

Use vzalloc() and vzalloc_node() in net drivers

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: Jon Mason <jon.mason@exar.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
89bf67f1 fe6d2a38

+39 -87
+2 -7
drivers/net/bnx2.c
··· 766 766 int j; 767 767 768 768 rxr->rx_buf_ring = 769 - vmalloc(SW_RXBD_RING_SIZE * bp->rx_max_ring); 769 + vzalloc(SW_RXBD_RING_SIZE * bp->rx_max_ring); 770 770 if (rxr->rx_buf_ring == NULL) 771 771 return -ENOMEM; 772 - 773 - memset(rxr->rx_buf_ring, 0, 774 - SW_RXBD_RING_SIZE * bp->rx_max_ring); 775 772 776 773 for (j = 0; j < bp->rx_max_ring; j++) { 777 774 rxr->rx_desc_ring[j] = ··· 782 785 } 783 786 784 787 if (bp->rx_pg_ring_size) { 785 - rxr->rx_pg_ring = vmalloc(SW_RXPG_RING_SIZE * 788 + rxr->rx_pg_ring = vzalloc(SW_RXPG_RING_SIZE * 786 789 bp->rx_max_pg_ring); 787 790 if (rxr->rx_pg_ring == NULL) 788 791 return -ENOMEM; 789 792 790 - memset(rxr->rx_pg_ring, 0, SW_RXPG_RING_SIZE * 791 - bp->rx_max_pg_ring); 792 793 } 793 794 794 795 for (j = 0; j < bp->rx_max_pg_ring; j++) {
+2 -4
drivers/net/cxgb3/cxgb3_offload.c
··· 1164 1164 */ 1165 1165 void *cxgb_alloc_mem(unsigned long size) 1166 1166 { 1167 - void *p = kmalloc(size, GFP_KERNEL); 1167 + void *p = kzalloc(size, GFP_KERNEL); 1168 1168 1169 1169 if (!p) 1170 - p = vmalloc(size); 1171 - if (p) 1172 - memset(p, 0, size); 1170 + p = vzalloc(size); 1173 1171 return p; 1174 1172 } 1175 1173
+2 -4
drivers/net/cxgb4/cxgb4_main.c
··· 868 868 */ 869 869 void *t4_alloc_mem(size_t size) 870 870 { 871 - void *p = kmalloc(size, GFP_KERNEL); 871 + void *p = kzalloc(size, GFP_KERNEL); 872 872 873 873 if (!p) 874 - p = vmalloc(size); 875 - if (p) 876 - memset(p, 0, size); 874 + p = vzalloc(size); 877 875 return p; 878 876 } 879 877
+2 -4
drivers/net/e1000/e1000_main.c
··· 1425 1425 int size; 1426 1426 1427 1427 size = sizeof(struct e1000_buffer) * txdr->count; 1428 - txdr->buffer_info = vmalloc(size); 1428 + txdr->buffer_info = vzalloc(size); 1429 1429 if (!txdr->buffer_info) { 1430 1430 e_err(probe, "Unable to allocate memory for the Tx descriptor " 1431 1431 "ring\n"); 1432 1432 return -ENOMEM; 1433 1433 } 1434 - memset(txdr->buffer_info, 0, size); 1435 1434 1436 1435 /* round up to nearest 4K */ 1437 1436 ··· 1620 1621 int size, desc_len; 1621 1622 1622 1623 size = sizeof(struct e1000_buffer) * rxdr->count; 1623 - rxdr->buffer_info = vmalloc(size); 1624 + rxdr->buffer_info = vzalloc(size); 1624 1625 if (!rxdr->buffer_info) { 1625 1626 e_err(probe, "Unable to allocate memory for the Rx descriptor " 1626 1627 "ring\n"); 1627 1628 return -ENOMEM; 1628 1629 } 1629 - memset(rxdr->buffer_info, 0, size); 1630 1630 1631 1631 desc_len = sizeof(struct e1000_rx_desc); 1632 1632
+2 -4
drivers/net/e1000e/netdev.c
··· 2059 2059 int err = -ENOMEM, size; 2060 2060 2061 2061 size = sizeof(struct e1000_buffer) * tx_ring->count; 2062 - tx_ring->buffer_info = vmalloc(size); 2062 + tx_ring->buffer_info = vzalloc(size); 2063 2063 if (!tx_ring->buffer_info) 2064 2064 goto err; 2065 - memset(tx_ring->buffer_info, 0, size); 2066 2065 2067 2066 /* round up to nearest 4K */ 2068 2067 tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc); ··· 2094 2095 int i, size, desc_len, err = -ENOMEM; 2095 2096 2096 2097 size = sizeof(struct e1000_buffer) * rx_ring->count; 2097 - rx_ring->buffer_info = vmalloc(size); 2098 + rx_ring->buffer_info = vzalloc(size); 2098 2099 if (!rx_ring->buffer_info) 2099 2100 goto err; 2100 - memset(rx_ring->buffer_info, 0, size); 2101 2101 2102 2102 for (i = 0; i < rx_ring->count; i++) { 2103 2103 buffer_info = &rx_ring->buffer_info[i];
+1 -3
drivers/net/ehea/ehea_main.c
··· 1496 1496 { 1497 1497 int arr_size = sizeof(void *) * max_q_entries; 1498 1498 1499 - q_skba->arr = vmalloc(arr_size); 1499 + q_skba->arr = vzalloc(arr_size); 1500 1500 if (!q_skba->arr) 1501 1501 return -ENOMEM; 1502 - 1503 - memset(q_skba->arr, 0, arr_size); 1504 1502 1505 1503 q_skba->len = max_q_entries; 1506 1504 q_skba->index = 0;
+2 -4
drivers/net/igb/igb_main.c
··· 2436 2436 int size; 2437 2437 2438 2438 size = sizeof(struct igb_buffer) * tx_ring->count; 2439 - tx_ring->buffer_info = vmalloc(size); 2439 + tx_ring->buffer_info = vzalloc(size); 2440 2440 if (!tx_ring->buffer_info) 2441 2441 goto err; 2442 - memset(tx_ring->buffer_info, 0, size); 2443 2442 2444 2443 /* round up to nearest 4K */ 2445 2444 tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc); ··· 2586 2587 int size, desc_len; 2587 2588 2588 2589 size = sizeof(struct igb_buffer) * rx_ring->count; 2589 - rx_ring->buffer_info = vmalloc(size); 2590 + rx_ring->buffer_info = vzalloc(size); 2590 2591 if (!rx_ring->buffer_info) 2591 2592 goto err; 2592 - memset(rx_ring->buffer_info, 0, size); 2593 2593 2594 2594 desc_len = sizeof(union e1000_adv_rx_desc); 2595 2595
+2 -4
drivers/net/igbvf/netdev.c
··· 430 430 int size; 431 431 432 432 size = sizeof(struct igbvf_buffer) * tx_ring->count; 433 - tx_ring->buffer_info = vmalloc(size); 433 + tx_ring->buffer_info = vzalloc(size); 434 434 if (!tx_ring->buffer_info) 435 435 goto err; 436 - memset(tx_ring->buffer_info, 0, size); 437 436 438 437 /* round up to nearest 4K */ 439 438 tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc); ··· 469 470 int size, desc_len; 470 471 471 472 size = sizeof(struct igbvf_buffer) * rx_ring->count; 472 - rx_ring->buffer_info = vmalloc(size); 473 + rx_ring->buffer_info = vzalloc(size); 473 474 if (!rx_ring->buffer_info) 474 475 goto err; 475 - memset(rx_ring->buffer_info, 0, size); 476 476 477 477 desc_len = sizeof(union e1000_adv_rx_desc); 478 478
+2 -4
drivers/net/ixgb/ixgb_main.c
··· 669 669 int size; 670 670 671 671 size = sizeof(struct ixgb_buffer) * txdr->count; 672 - txdr->buffer_info = vmalloc(size); 672 + txdr->buffer_info = vzalloc(size); 673 673 if (!txdr->buffer_info) { 674 674 netif_err(adapter, probe, adapter->netdev, 675 675 "Unable to allocate transmit descriptor ring memory\n"); 676 676 return -ENOMEM; 677 677 } 678 - memset(txdr->buffer_info, 0, size); 679 678 680 679 /* round up to nearest 4K */ 681 680 ··· 758 759 int size; 759 760 760 761 size = sizeof(struct ixgb_buffer) * rxdr->count; 761 - rxdr->buffer_info = vmalloc(size); 762 + rxdr->buffer_info = vzalloc(size); 762 763 if (!rxdr->buffer_info) { 763 764 netif_err(adapter, probe, adapter->netdev, 764 765 "Unable to allocate receive descriptor ring\n"); 765 766 return -ENOMEM; 766 767 } 767 - memset(rxdr->buffer_info, 0, size); 768 768 769 769 /* Round up to nearest 4K */ 770 770
+4 -6
drivers/net/ixgbe/ixgbe_main.c
··· 5181 5181 int size; 5182 5182 5183 5183 size = sizeof(struct ixgbe_tx_buffer) * tx_ring->count; 5184 - tx_ring->tx_buffer_info = vmalloc_node(size, tx_ring->numa_node); 5184 + tx_ring->tx_buffer_info = vzalloc_node(size, tx_ring->numa_node); 5185 5185 if (!tx_ring->tx_buffer_info) 5186 - tx_ring->tx_buffer_info = vmalloc(size); 5186 + tx_ring->tx_buffer_info = vzalloc(size); 5187 5187 if (!tx_ring->tx_buffer_info) 5188 5188 goto err; 5189 - memset(tx_ring->tx_buffer_info, 0, size); 5190 5189 5191 5190 /* round up to nearest 4K */ 5192 5191 tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc); ··· 5245 5246 int size; 5246 5247 5247 5248 size = sizeof(struct ixgbe_rx_buffer) * rx_ring->count; 5248 - rx_ring->rx_buffer_info = vmalloc_node(size, rx_ring->numa_node); 5249 + rx_ring->rx_buffer_info = vzalloc_node(size, rx_ring->numa_node); 5249 5250 if (!rx_ring->rx_buffer_info) 5250 - rx_ring->rx_buffer_info = vmalloc(size); 5251 + rx_ring->rx_buffer_info = vzalloc(size); 5251 5252 if (!rx_ring->rx_buffer_info) 5252 5253 goto err; 5253 - memset(rx_ring->rx_buffer_info, 0, size); 5254 5254 5255 5255 /* Round up to nearest 4K */ 5256 5256 rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc);
+2 -4
drivers/net/ixgbevf/ixgbevf_main.c
··· 2489 2489 int size; 2490 2490 2491 2491 size = sizeof(struct ixgbevf_tx_buffer) * tx_ring->count; 2492 - tx_ring->tx_buffer_info = vmalloc(size); 2492 + tx_ring->tx_buffer_info = vzalloc(size); 2493 2493 if (!tx_ring->tx_buffer_info) 2494 2494 goto err; 2495 - memset(tx_ring->tx_buffer_info, 0, size); 2496 2495 2497 2496 /* round up to nearest 4K */ 2498 2497 tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc); ··· 2555 2556 int size; 2556 2557 2557 2558 size = sizeof(struct ixgbevf_rx_buffer) * rx_ring->count; 2558 - rx_ring->rx_buffer_info = vmalloc(size); 2559 + rx_ring->rx_buffer_info = vzalloc(size); 2559 2560 if (!rx_ring->rx_buffer_info) { 2560 2561 hw_dbg(&adapter->hw, 2561 2562 "Unable to vmalloc buffer memory for " 2562 2563 "the receive descriptor ring\n"); 2563 2564 goto alloc_failed; 2564 2565 } 2565 - memset(rx_ring->rx_buffer_info, 0, size); 2566 2566 2567 2567 /* Round up to nearest 4K */ 2568 2568 rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc);
+2 -4
drivers/net/netxen/netxen_nic_init.c
··· 214 214 tx_ring->num_desc = adapter->num_txd; 215 215 tx_ring->txq = netdev_get_tx_queue(netdev, 0); 216 216 217 - cmd_buf_arr = vmalloc(TX_BUFF_RINGSIZE(tx_ring)); 217 + cmd_buf_arr = vzalloc(TX_BUFF_RINGSIZE(tx_ring)); 218 218 if (cmd_buf_arr == NULL) { 219 219 dev_err(&pdev->dev, "%s: failed to allocate cmd buffer ring\n", 220 220 netdev->name); 221 221 goto err_out; 222 222 } 223 - memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(tx_ring)); 224 223 tx_ring->cmd_buf_arr = cmd_buf_arr; 225 224 226 225 recv_ctx = &adapter->recv_ctx; ··· 279 280 280 281 } 281 282 rds_ring->rx_buf_arr = (struct netxen_rx_buffer *) 282 - vmalloc(RCV_BUFF_RINGSIZE(rds_ring)); 283 + vzalloc(RCV_BUFF_RINGSIZE(rds_ring)); 283 284 if (rds_ring->rx_buf_arr == NULL) { 284 285 printk(KERN_ERR "%s: Failed to allocate " 285 286 "rx buffer ring %d\n", ··· 287 288 /* free whatever was already allocated */ 288 289 goto err_out; 289 290 } 290 - memset(rds_ring->rx_buf_arr, 0, RCV_BUFF_RINGSIZE(rds_ring)); 291 291 INIT_LIST_HEAD(&rds_ring->free_list); 292 292 /* 293 293 * Now go through all of them, set reference handles
+2 -4
drivers/net/pch_gbe/pch_gbe_main.c
··· 1523 1523 int desNo; 1524 1524 1525 1525 size = (int)sizeof(struct pch_gbe_buffer) * tx_ring->count; 1526 - tx_ring->buffer_info = vmalloc(size); 1526 + tx_ring->buffer_info = vzalloc(size); 1527 1527 if (!tx_ring->buffer_info) { 1528 1528 pr_err("Unable to allocate memory for the buffer infomation\n"); 1529 1529 return -ENOMEM; 1530 1530 } 1531 - memset(tx_ring->buffer_info, 0, size); 1532 1531 1533 1532 tx_ring->size = tx_ring->count * (int)sizeof(struct pch_gbe_tx_desc); 1534 1533 ··· 1572 1573 int desNo; 1573 1574 1574 1575 size = (int)sizeof(struct pch_gbe_buffer) * rx_ring->count; 1575 - rx_ring->buffer_info = vmalloc(size); 1576 + rx_ring->buffer_info = vzalloc(size); 1576 1577 if (!rx_ring->buffer_info) { 1577 1578 pr_err("Unable to allocate memory for the receive descriptor ring\n"); 1578 1579 return -ENOMEM; 1579 1580 } 1580 - memset(rx_ring->buffer_info, 0, size); 1581 1581 rx_ring->size = rx_ring->count * (int)sizeof(struct pch_gbe_rx_desc); 1582 1582 rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size, 1583 1583 &rx_ring->dma, GFP_KERNEL);
+1 -2
drivers/net/pptp.c
··· 673 673 int err = 0; 674 674 pr_info("PPTP driver version " PPTP_DRIVER_VERSION "\n"); 675 675 676 - callid_sock = __vmalloc((MAX_CALLID + 1) * sizeof(void *), 677 - GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL); 676 + callid_sock = vzalloc((MAX_CALLID + 1) * sizeof(void *)); 678 677 if (!callid_sock) { 679 678 pr_err("PPTP: cann't allocate memory\n"); 680 679 return -ENOMEM;
+2 -4
drivers/net/qlcnic/qlcnic_init.c
··· 236 236 tx_ring->num_desc = adapter->num_txd; 237 237 tx_ring->txq = netdev_get_tx_queue(netdev, 0); 238 238 239 - cmd_buf_arr = vmalloc(TX_BUFF_RINGSIZE(tx_ring)); 239 + cmd_buf_arr = vzalloc(TX_BUFF_RINGSIZE(tx_ring)); 240 240 if (cmd_buf_arr == NULL) { 241 241 dev_err(&netdev->dev, "failed to allocate cmd buffer ring\n"); 242 242 goto err_out; 243 243 } 244 - memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(tx_ring)); 245 244 tx_ring->cmd_buf_arr = cmd_buf_arr; 246 245 247 246 recv_ctx = &adapter->recv_ctx; ··· 275 276 break; 276 277 } 277 278 rds_ring->rx_buf_arr = (struct qlcnic_rx_buffer *) 278 - vmalloc(RCV_BUFF_RINGSIZE(rds_ring)); 279 + vzalloc(RCV_BUFF_RINGSIZE(rds_ring)); 279 280 if (rds_ring->rx_buf_arr == NULL) { 280 281 dev_err(&netdev->dev, "Failed to allocate " 281 282 "rx buffer ring %d\n", ring); 282 283 goto err_out; 283 284 } 284 - memset(rds_ring->rx_buf_arr, 0, RCV_BUFF_RINGSIZE(rds_ring)); 285 285 INIT_LIST_HEAD(&rds_ring->free_list); 286 286 /* 287 287 * Now go through all of them, set reference handles
+1 -2
drivers/net/sfc/filter.c
··· 428 428 GFP_KERNEL); 429 429 if (!table->used_bitmap) 430 430 goto fail; 431 - table->spec = vmalloc(table->size * sizeof(*table->spec)); 431 + table->spec = vzalloc(table->size * sizeof(*table->spec)); 432 432 if (!table->spec) 433 433 goto fail; 434 - memset(table->spec, 0, table->size * sizeof(*table->spec)); 435 434 } 436 435 437 436 return 0;
+8 -23
drivers/net/vxge/vxge-config.c
··· 1220 1220 goto exit; 1221 1221 1222 1222 hldev = (struct __vxge_hw_device *) 1223 - vmalloc(sizeof(struct __vxge_hw_device)); 1223 + vzalloc(sizeof(struct __vxge_hw_device)); 1224 1224 if (hldev == NULL) { 1225 1225 status = VXGE_HW_ERR_OUT_OF_MEMORY; 1226 1226 goto exit; 1227 1227 } 1228 1228 1229 - memset(hldev, 0, sizeof(struct __vxge_hw_device)); 1230 1229 hldev->magic = VXGE_HW_DEVICE_MAGIC; 1231 1230 1232 1231 vxge_hw_device_debug_set(hldev, VXGE_ERR, VXGE_COMPONENT_ALL); ··· 2063 2064 * allocate new memblock and its private part at once. 2064 2065 * This helps to minimize memory usage a lot. */ 2065 2066 mempool->memblocks_priv_arr[i] = 2066 - vmalloc(mempool->items_priv_size * n_items); 2067 + vzalloc(mempool->items_priv_size * n_items); 2067 2068 if (mempool->memblocks_priv_arr[i] == NULL) { 2068 2069 status = VXGE_HW_ERR_OUT_OF_MEMORY; 2069 2070 goto exit; 2070 2071 } 2071 - 2072 - memset(mempool->memblocks_priv_arr[i], 0, 2073 - mempool->items_priv_size * n_items); 2074 2072 2075 2073 /* allocate DMA-capable memblock */ 2076 2074 mempool->memblocks_arr[i] = ··· 2141 2145 } 2142 2146 2143 2147 mempool = (struct vxge_hw_mempool *) 2144 - vmalloc(sizeof(struct vxge_hw_mempool)); 2148 + vzalloc(sizeof(struct vxge_hw_mempool)); 2145 2149 if (mempool == NULL) { 2146 2150 status = VXGE_HW_ERR_OUT_OF_MEMORY; 2147 2151 goto exit; 2148 2152 } 2149 - memset(mempool, 0, sizeof(struct vxge_hw_mempool)); 2150 2153 2151 2154 mempool->devh = devh; 2152 2155 mempool->memblock_size = memblock_size; ··· 2165 2170 2166 2171 /* allocate array of memblocks */ 2167 2172 mempool->memblocks_arr = 2168 - (void **) vmalloc(sizeof(void *) * mempool->memblocks_max); 2173 + (void **) vzalloc(sizeof(void *) * mempool->memblocks_max); 2169 2174 if (mempool->memblocks_arr == NULL) { 2170 2175 __vxge_hw_mempool_destroy(mempool); 2171 2176 status = VXGE_HW_ERR_OUT_OF_MEMORY; 2172 2177 mempool = NULL; 2173 2178 goto exit; 2174 2179 } 2175 - memset(mempool->memblocks_arr, 0, 2176 - sizeof(void *) * mempool->memblocks_max); 2177 2180 2178 2181 /* allocate array of private parts of items per memblocks */ 2179 2182 mempool->memblocks_priv_arr = 2180 - (void **) vmalloc(sizeof(void *) * mempool->memblocks_max); 2183 + (void **) vzalloc(sizeof(void *) * mempool->memblocks_max); 2181 2184 if (mempool->memblocks_priv_arr == NULL) { 2182 2185 __vxge_hw_mempool_destroy(mempool); 2183 2186 status = VXGE_HW_ERR_OUT_OF_MEMORY; 2184 2187 mempool = NULL; 2185 2188 goto exit; 2186 2189 } 2187 - memset(mempool->memblocks_priv_arr, 0, 2188 - sizeof(void *) * mempool->memblocks_max); 2189 2190 2190 2191 /* allocate array of memblocks DMA objects */ 2191 2192 mempool->memblocks_dma_arr = (struct vxge_hw_mempool_dma *) 2192 - vmalloc(sizeof(struct vxge_hw_mempool_dma) * 2193 + vzalloc(sizeof(struct vxge_hw_mempool_dma) * 2193 2194 mempool->memblocks_max); 2194 2195 2195 2196 if (mempool->memblocks_dma_arr == NULL) { ··· 2194 2203 mempool = NULL; 2195 2204 goto exit; 2196 2205 } 2197 - memset(mempool->memblocks_dma_arr, 0, 2198 - sizeof(struct vxge_hw_mempool_dma) * 2199 - mempool->memblocks_max); 2200 2206 2201 2207 /* allocate hash array of items */ 2202 2208 mempool->items_arr = 2203 - (void **) vmalloc(sizeof(void *) * mempool->items_max); 2209 + (void **) vzalloc(sizeof(void *) * mempool->items_max); 2204 2210 if (mempool->items_arr == NULL) { 2205 2211 __vxge_hw_mempool_destroy(mempool); 2206 2212 status = VXGE_HW_ERR_OUT_OF_MEMORY; 2207 2213 mempool = NULL; 2208 2214 goto exit; 2209 2215 } 2210 - memset(mempool->items_arr, 0, sizeof(void *) * mempool->items_max); 2211 2216 2212 2217 /* calculate initial number of memblocks */ 2213 2218 memblocks_to_allocate = (mempool->items_initial + ··· 4259 4272 goto vpath_open_exit1; 4260 4273 4261 4274 vp = (struct __vxge_hw_vpath_handle *) 4262 - vmalloc(sizeof(struct __vxge_hw_vpath_handle)); 4275 + vzalloc(sizeof(struct __vxge_hw_vpath_handle)); 4263 4276 if (vp == NULL) { 4264 4277 status = VXGE_HW_ERR_OUT_OF_MEMORY; 4265 4278 goto vpath_open_exit2; 4266 4279 } 4267 - 4268 - memset(vp, 0, sizeof(struct __vxge_hw_vpath_handle)); 4269 4280 4270 4281 vp->vpath = vpath; 4271 4282