ethernet: Remove unnecessary alloc/OOM messages, alloc cleanups

alloc failures already get standardized OOM
messages and a dump_stack.

Convert kzalloc's with multiplies to kcalloc.
Convert kmalloc's with multiplies to kmalloc_array.
Fix a few whitespace defects.
Convert a constant 6 to ETH_ALEN.
Use parentheses around sizeof.
Convert vmalloc/memset to vzalloc.
Remove now unused size variables.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Joe Perches 2013-02-03 17:43:58 +00:00 коммит произвёл David S. Miller
Родитель 09da6c5f60
Коммит b2adaca92c
38 изменённых файлов: 97 добавлений и 197 удалений

Просмотреть файл

@ -982,11 +982,9 @@ static int atl1c_setup_ring_resources(struct atl1c_adapter *adapter)
size = sizeof(struct atl1c_buffer) * (tpd_ring->count * 2 + size = sizeof(struct atl1c_buffer) * (tpd_ring->count * 2 +
rfd_ring->count); rfd_ring->count);
tpd_ring->buffer_info = kzalloc(size, GFP_KERNEL); tpd_ring->buffer_info = kzalloc(size, GFP_KERNEL);
if (unlikely(!tpd_ring->buffer_info)) { if (unlikely(!tpd_ring->buffer_info))
dev_err(&pdev->dev, "kzalloc failed, size = %d\n",
size);
goto err_nomem; goto err_nomem;
}
for (i = 0; i < AT_MAX_TRANSMIT_QUEUE; i++) { for (i = 0; i < AT_MAX_TRANSMIT_QUEUE; i++) {
tpd_ring[i].buffer_info = tpd_ring[i].buffer_info =
(tpd_ring->buffer_info + count); (tpd_ring->buffer_info + count);

Просмотреть файл

@ -819,8 +819,6 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
size = sizeof(struct atl1e_tx_buffer) * (tx_ring->count); size = sizeof(struct atl1e_tx_buffer) * (tx_ring->count);
tx_ring->tx_buffer = kzalloc(size, GFP_KERNEL); tx_ring->tx_buffer = kzalloc(size, GFP_KERNEL);
if (tx_ring->tx_buffer == NULL) { if (tx_ring->tx_buffer == NULL) {
netdev_err(adapter->netdev, "kzalloc failed, size = D%d\n",
size);
err = -ENOMEM; err = -ENOMEM;
goto failed; goto failed;
} }

Просмотреть файл

@ -1518,10 +1518,8 @@ static void b44_setup_pseudo_magicp(struct b44 *bp)
u8 pwol_mask[B44_PMASK_SIZE]; u8 pwol_mask[B44_PMASK_SIZE];
pwol_pattern = kzalloc(B44_PATTERN_SIZE, GFP_KERNEL); pwol_pattern = kzalloc(B44_PATTERN_SIZE, GFP_KERNEL);
if (!pwol_pattern) { if (!pwol_pattern)
pr_err("Memory not available for WOL\n");
return; return;
}
/* Ipv4 magic packet pattern - pattern 0.*/ /* Ipv4 magic packet pattern - pattern 0.*/
memset(pwol_mask, 0, B44_PMASK_SIZE); memset(pwol_mask, 0, B44_PMASK_SIZE);

Просмотреть файл

@ -886,10 +886,9 @@ static int bcm_enet_open(struct net_device *dev)
priv->tx_desc_alloc_size = size; priv->tx_desc_alloc_size = size;
priv->tx_desc_cpu = p; priv->tx_desc_cpu = p;
priv->tx_skb = kzalloc(sizeof(struct sk_buff *) * priv->tx_ring_size, priv->tx_skb = kcalloc(priv->tx_ring_size, sizeof(struct sk_buff *),
GFP_KERNEL); GFP_KERNEL);
if (!priv->tx_skb) { if (!priv->tx_skb) {
dev_err(kdev, "cannot allocate rx skb queue\n");
ret = -ENOMEM; ret = -ENOMEM;
goto out_free_tx_ring; goto out_free_tx_ring;
} }
@ -900,10 +899,9 @@ static int bcm_enet_open(struct net_device *dev)
spin_lock_init(&priv->tx_lock); spin_lock_init(&priv->tx_lock);
/* init & fill rx ring with skbs */ /* init & fill rx ring with skbs */
priv->rx_skb = kzalloc(sizeof(struct sk_buff *) * priv->rx_ring_size, priv->rx_skb = kcalloc(priv->rx_ring_size, sizeof(struct sk_buff *),
GFP_KERNEL); GFP_KERNEL);
if (!priv->rx_skb) { if (!priv->rx_skb) {
dev_err(kdev, "cannot allocate rx skb queue\n");
ret = -ENOMEM; ret = -ENOMEM;
goto out_free_tx_skb; goto out_free_tx_skb;
} }

Просмотреть файл

@ -5425,11 +5425,9 @@ static struct cnic_dev *cnic_alloc_dev(struct net_device *dev,
alloc_size = sizeof(struct cnic_dev) + sizeof(struct cnic_local); alloc_size = sizeof(struct cnic_dev) + sizeof(struct cnic_local);
cdev = kzalloc(alloc_size , GFP_KERNEL); cdev = kzalloc(alloc_size, GFP_KERNEL);
if (cdev == NULL) { if (cdev == NULL)
netdev_err(dev, "allocate dev struct failure\n");
return NULL; return NULL;
}
cdev->netdev = dev; cdev->netdev = dev;
cdev->cnic_priv = (char *)cdev + sizeof(struct cnic_dev); cdev->cnic_priv = (char *)cdev + sizeof(struct cnic_dev);

Просмотреть файл

@ -5793,10 +5793,8 @@ static void tg3_dump_state(struct tg3 *tp)
u32 *regs; u32 *regs;
regs = kzalloc(TG3_REG_BLK_SIZE, GFP_ATOMIC); regs = kzalloc(TG3_REG_BLK_SIZE, GFP_ATOMIC);
if (!regs) { if (!regs)
netdev_err(tp->dev, "Failed allocating register dump buffer\n");
return; return;
}
if (tg3_flag(tp, PCI_EXPRESS)) { if (tg3_flag(tp, PCI_EXPRESS)) {
/* Read up to but not including private PCI registers */ /* Read up to but not including private PCI registers */

Просмотреть файл

@ -716,12 +716,11 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
int j = MAX_FILER_IDX, l = 0x0; int j = MAX_FILER_IDX, l = 0x0;
int ret = 1; int ret = 1;
local_rqfpr = kmalloc(sizeof(unsigned int) * (MAX_FILER_IDX + 1), local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
GFP_KERNEL); GFP_KERNEL);
local_rqfcr = kmalloc(sizeof(unsigned int) * (MAX_FILER_IDX + 1), local_rqfcr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
GFP_KERNEL); GFP_KERNEL);
if (!local_rqfpr || !local_rqfcr) { if (!local_rqfpr || !local_rqfcr) {
pr_err("Out of memory\n");
ret = 0; ret = 0;
goto err; goto err;
} }

Просмотреть файл

@ -1921,10 +1921,8 @@ static void ehea_add_multicast_entry(struct ehea_port *port, u8 *mc_mac_addr)
u64 hret; u64 hret;
ehea_mcl_entry = kzalloc(sizeof(*ehea_mcl_entry), GFP_ATOMIC); ehea_mcl_entry = kzalloc(sizeof(*ehea_mcl_entry), GFP_ATOMIC);
if (!ehea_mcl_entry) { if (!ehea_mcl_entry)
pr_err("no mem for mcl_entry\n");
return; return;
}
INIT_LIST_HEAD(&ehea_mcl_entry->list); INIT_LIST_HEAD(&ehea_mcl_entry->list);

Просмотреть файл

@ -64,11 +64,10 @@ static int hw_queue_ctor(struct hw_queue *queue, const u32 nr_of_pages,
} }
queue->queue_length = nr_of_pages * pagesize; queue->queue_length = nr_of_pages * pagesize;
queue->queue_pages = kmalloc(nr_of_pages * sizeof(void *), GFP_KERNEL); queue->queue_pages = kmalloc_array(nr_of_pages, sizeof(void *),
if (!queue->queue_pages) { GFP_KERNEL);
pr_err("no mem for queue_pages\n"); if (!queue->queue_pages)
return -ENOMEM; return -ENOMEM;
}
/* /*
* allocate pages for queue: * allocate pages for queue:
@ -129,10 +128,8 @@ struct ehea_cq *ehea_create_cq(struct ehea_adapter *adapter,
void *vpage; void *vpage;
cq = kzalloc(sizeof(*cq), GFP_KERNEL); cq = kzalloc(sizeof(*cq), GFP_KERNEL);
if (!cq) { if (!cq)
pr_err("no mem for cq\n");
goto out_nomem; goto out_nomem;
}
cq->attr.max_nr_of_cqes = nr_of_cqe; cq->attr.max_nr_of_cqes = nr_of_cqe;
cq->attr.cq_token = cq_token; cq->attr.cq_token = cq_token;
@ -257,10 +254,8 @@ struct ehea_eq *ehea_create_eq(struct ehea_adapter *adapter,
struct ehea_eq *eq; struct ehea_eq *eq;
eq = kzalloc(sizeof(*eq), GFP_KERNEL); eq = kzalloc(sizeof(*eq), GFP_KERNEL);
if (!eq) { if (!eq)
pr_err("no mem for eq\n");
return NULL; return NULL;
}
eq->adapter = adapter; eq->adapter = adapter;
eq->attr.type = type; eq->attr.type = type;
@ -428,10 +423,8 @@ struct ehea_qp *ehea_create_qp(struct ehea_adapter *adapter,
qp = kzalloc(sizeof(*qp), GFP_KERNEL); qp = kzalloc(sizeof(*qp), GFP_KERNEL);
if (!qp) { if (!qp)
pr_err("no mem for qp\n");
return NULL; return NULL;
}
qp->adapter = adapter; qp->adapter = adapter;

Просмотреть файл

@ -528,12 +528,9 @@ static int mal_probe(struct platform_device *ofdev)
irq_handler_t hdlr_serr, hdlr_txde, hdlr_rxde; irq_handler_t hdlr_serr, hdlr_txde, hdlr_rxde;
mal = kzalloc(sizeof(struct mal_instance), GFP_KERNEL); mal = kzalloc(sizeof(struct mal_instance), GFP_KERNEL);
if (!mal) { if (!mal)
printk(KERN_ERR
"mal%d: out of memory allocating MAL structure!\n",
index);
return -ENOMEM; return -ENOMEM;
}
mal->index = index; mal->index = index;
mal->ofdev = ofdev; mal->ofdev = ofdev;
mal->version = of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal2") ? 2 : 1; mal->version = of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal2") ? 2 : 1;

Просмотреть файл

@ -637,7 +637,6 @@ static int ibmveth_open(struct net_device *netdev)
adapter->bounce_buffer = adapter->bounce_buffer =
kmalloc(netdev->mtu + IBMVETH_BUFF_OH, GFP_KERNEL); kmalloc(netdev->mtu + IBMVETH_BUFF_OH, GFP_KERNEL);
if (!adapter->bounce_buffer) { if (!adapter->bounce_buffer) {
netdev_err(netdev, "unable to allocate bounce buffer\n");
rc = -ENOMEM; rc = -ENOMEM;
goto err_out_free_irq; goto err_out_free_irq;
} }

Просмотреть файл

@ -2671,9 +2671,8 @@ static int igb_sw_init(struct igb_adapter *adapter)
igb_init_queue_configuration(adapter); igb_init_queue_configuration(adapter);
/* Setup and initialize a copy of the hw vlan table array */ /* Setup and initialize a copy of the hw vlan table array */
adapter->shadow_vfta = kzalloc(sizeof(u32) * adapter->shadow_vfta = kcalloc(E1000_VLAN_FILTER_TBL_SIZE, sizeof(u32),
E1000_VLAN_FILTER_TBL_SIZE, GFP_ATOMIC);
GFP_ATOMIC);
/* This call may decrease the number of queues */ /* This call may decrease the number of queues */
if (igb_init_interrupt_scheme(adapter, true)) { if (igb_init_interrupt_scheme(adapter, true)) {

Просмотреть файл

@ -1399,12 +1399,10 @@ static void igbvf_set_multi(struct net_device *netdev)
int i; int i;
if (!netdev_mc_empty(netdev)) { if (!netdev_mc_empty(netdev)) {
mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC); mta_list = kmalloc_array(netdev_mc_count(netdev), ETH_ALEN,
if (!mta_list) { GFP_ATOMIC);
dev_err(&adapter->pdev->dev, if (!mta_list)
"failed to allocate multicast filter list\n");
return; return;
}
} }
/* prepare a packed array of only addresses. */ /* prepare a packed array of only addresses. */

Просмотреть файл

@ -1879,12 +1879,10 @@ static int rxq_init(struct mv643xx_eth_private *mp, int index)
memset(rxq->rx_desc_area, 0, size); memset(rxq->rx_desc_area, 0, size);
rxq->rx_desc_area_size = size; rxq->rx_desc_area_size = size;
rxq->rx_skb = kmalloc(rxq->rx_ring_size * sizeof(*rxq->rx_skb), rxq->rx_skb = kmalloc_array(rxq->rx_ring_size, sizeof(*rxq->rx_skb),
GFP_KERNEL); GFP_KERNEL);
if (rxq->rx_skb == NULL) { if (rxq->rx_skb == NULL)
netdev_err(mp->dev, "can't allocate rx skb ring\n");
goto out_free; goto out_free;
}
rx_desc = rxq->rx_desc_area; rx_desc = rxq->rx_desc_area;
for (i = 0; i < rxq->rx_ring_size; i++) { for (i = 0; i < rxq->rx_ring_size; i++) {

Просмотреть файл

@ -164,7 +164,6 @@ static int orion_mdio_probe(struct platform_device *pdev)
bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
if (!bus->irq) { if (!bus->irq) {
dev_err(&pdev->dev, "Cannot allocate PHY IRQ array\n");
mdiobus_free(bus); mdiobus_free(bus);
return -ENOMEM; return -ENOMEM;
} }

Просмотреть файл

@ -3916,10 +3916,9 @@ static int skge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
/* space for skge@pci:0000:04:00.0 */ /* space for skge@pci:0000:04:00.0 */
hw = kzalloc(sizeof(*hw) + strlen(DRV_NAME "@pci:") hw = kzalloc(sizeof(*hw) + strlen(DRV_NAME "@pci:")
+ strlen(pci_name(pdev)) + 1, GFP_KERNEL); + strlen(pci_name(pdev)) + 1, GFP_KERNEL);
if (!hw) { if (!hw)
dev_err(&pdev->dev, "cannot allocate hardware struct\n");
goto err_out_free_regions; goto err_out_free_regions;
}
sprintf(hw->irq_name, DRV_NAME "@pci:%s", pci_name(pdev)); sprintf(hw->irq_name, DRV_NAME "@pci:%s", pci_name(pdev));
hw->pdev = pdev; hw->pdev = pdev;

Просмотреть файл

@ -4969,10 +4969,8 @@ static int sky2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
hw = kzalloc(sizeof(*hw) + strlen(DRV_NAME "@pci:") hw = kzalloc(sizeof(*hw) + strlen(DRV_NAME "@pci:")
+ strlen(pci_name(pdev)) + 1, GFP_KERNEL); + strlen(pci_name(pdev)) + 1, GFP_KERNEL);
if (!hw) { if (!hw)
dev_err(&pdev->dev, "cannot allocate hardware struct\n");
goto err_out_free_regions; goto err_out_free_regions;
}
hw->pdev = pdev; hw->pdev = pdev;
sprintf(hw->irq_name, DRV_NAME "@pci:%s", pci_name(pdev)); sprintf(hw->irq_name, DRV_NAME "@pci:%s", pci_name(pdev));

Просмотреть файл

@ -191,10 +191,8 @@ static void *mlx4_en_add(struct mlx4_dev *dev)
printk_once(KERN_INFO "%s", mlx4_en_version); printk_once(KERN_INFO "%s", mlx4_en_version);
mdev = kzalloc(sizeof *mdev, GFP_KERNEL); mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev) { if (!mdev) {
dev_err(&dev->pdev->dev, "Device struct alloc failed, "
"aborting.\n");
err = -ENOMEM; err = -ENOMEM;
goto err_free_res; goto err_free_res;
} }

Просмотреть файл

@ -2054,10 +2054,8 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data)
/* Allow large DMA segments, up to the firmware limit of 1 GB */ /* Allow large DMA segments, up to the firmware limit of 1 GB */
dma_set_max_seg_size(&pdev->dev, 1024 * 1024 * 1024); dma_set_max_seg_size(&pdev->dev, 1024 * 1024 * 1024);
priv = kzalloc(sizeof *priv, GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) { if (!priv) {
dev_err(&pdev->dev, "Device struct alloc failed, "
"aborting.\n");
err = -ENOMEM; err = -ENOMEM;
goto err_release_regions; goto err_release_regions;
} }

Просмотреть файл

@ -664,10 +664,9 @@ static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp)
/* copy header of running firmware from SRAM to host memory to /* copy header of running firmware from SRAM to host memory to
* validate firmware */ * validate firmware */
hdr = kmalloc(bytes, GFP_KERNEL); hdr = kmalloc(bytes, GFP_KERNEL);
if (hdr == NULL) { if (hdr == NULL)
dev_err(dev, "could not malloc firmware hdr\n");
return -ENOMEM; return -ENOMEM;
}
memcpy_fromio(hdr, mgp->sram + hdr_offset, bytes); memcpy_fromio(hdr, mgp->sram + hdr_offset, bytes);
status = myri10ge_validate_firmware(mgp, hdr); status = myri10ge_validate_firmware(mgp, hdr);
kfree(hdr); kfree(hdr);

Просмотреть файл

@ -201,11 +201,8 @@ netxen_setup_minidump(struct netxen_adapter *adapter)
adapter->mdump.md_template = adapter->mdump.md_template =
kmalloc(adapter->mdump.md_template_size, GFP_KERNEL); kmalloc(adapter->mdump.md_template_size, GFP_KERNEL);
if (!adapter->mdump.md_template) { if (!adapter->mdump.md_template)
dev_err(&adapter->pdev->dev, "Unable to allocate memory "
"for minidump template.\n");
return -ENOMEM; return -ENOMEM;
}
err = netxen_get_minidump_template(adapter); err = netxen_get_minidump_template(adapter);
if (err) { if (err) {

Просмотреть файл

@ -670,11 +670,9 @@ static int nx_p3_nic_add_mac(struct netxen_adapter *adapter,
} }
cur = kzalloc(sizeof(nx_mac_list_t), GFP_ATOMIC); cur = kzalloc(sizeof(nx_mac_list_t), GFP_ATOMIC);
if (cur == NULL) { if (cur == NULL)
printk(KERN_ERR "%s: failed to add mac address filter\n",
adapter->netdev->name);
return -ENOMEM; return -ENOMEM;
}
memcpy(cur->mac_addr, addr, ETH_ALEN); memcpy(cur->mac_addr, addr, ETH_ALEN);
list_add_tail(&cur->list, &adapter->mac_list); list_add_tail(&cur->list, &adapter->mac_list);
return nx_p3_sre_macaddr_change(adapter, return nx_p3_sre_macaddr_change(adapter,
@ -2568,16 +2566,10 @@ netxen_dump_fw(struct netxen_adapter *adapter)
adapter->mdump.md_capture_size; adapter->mdump.md_capture_size;
if (!adapter->mdump.md_capture_buff) { if (!adapter->mdump.md_capture_buff) {
adapter->mdump.md_capture_buff = adapter->mdump.md_capture_buff =
vmalloc(adapter->mdump.md_dump_size); vzalloc(adapter->mdump.md_dump_size);
if (!adapter->mdump.md_capture_buff) { if (!adapter->mdump.md_capture_buff)
dev_info(&adapter->pdev->dev,
"Unable to allocate memory for minidump "
"capture_buffer(%d bytes).\n",
adapter->mdump.md_dump_size);
return; return;
}
memset(adapter->mdump.md_capture_buff, 0,
adapter->mdump.md_dump_size);
if (netxen_collect_minidump(adapter)) { if (netxen_collect_minidump(adapter)) {
adapter->mdump.has_valid_dump = 0; adapter->mdump.has_valid_dump = 0;
adapter->mdump.md_dump_size = 0; adapter->mdump.md_dump_size = 0;

Просмотреть файл

@ -197,41 +197,34 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
struct nx_host_sds_ring *sds_ring; struct nx_host_sds_ring *sds_ring;
struct nx_host_tx_ring *tx_ring; struct nx_host_tx_ring *tx_ring;
struct netxen_rx_buffer *rx_buf; struct netxen_rx_buffer *rx_buf;
int ring, i, size; int ring, i;
struct netxen_cmd_buffer *cmd_buf_arr; struct netxen_cmd_buffer *cmd_buf_arr;
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
size = sizeof(struct nx_host_tx_ring); tx_ring = kzalloc(sizeof(struct nx_host_tx_ring), GFP_KERNEL);
tx_ring = kzalloc(size, GFP_KERNEL); if (tx_ring == NULL)
if (tx_ring == NULL) {
dev_err(&pdev->dev, "%s: failed to allocate tx ring struct\n",
netdev->name);
return -ENOMEM; return -ENOMEM;
}
adapter->tx_ring = tx_ring; adapter->tx_ring = tx_ring;
tx_ring->num_desc = adapter->num_txd; tx_ring->num_desc = adapter->num_txd;
tx_ring->txq = netdev_get_tx_queue(netdev, 0); tx_ring->txq = netdev_get_tx_queue(netdev, 0);
cmd_buf_arr = vzalloc(TX_BUFF_RINGSIZE(tx_ring)); cmd_buf_arr = vzalloc(TX_BUFF_RINGSIZE(tx_ring));
if (cmd_buf_arr == NULL) { if (cmd_buf_arr == NULL)
dev_err(&pdev->dev, "%s: failed to allocate cmd buffer ring\n",
netdev->name);
goto err_out; goto err_out;
}
tx_ring->cmd_buf_arr = cmd_buf_arr; tx_ring->cmd_buf_arr = cmd_buf_arr;
recv_ctx = &adapter->recv_ctx; recv_ctx = &adapter->recv_ctx;
size = adapter->max_rds_rings * sizeof (struct nx_host_rds_ring); rds_ring = kcalloc(adapter->max_rds_rings,
rds_ring = kzalloc(size, GFP_KERNEL); sizeof(struct nx_host_rds_ring), GFP_KERNEL);
if (rds_ring == NULL) { if (rds_ring == NULL)
dev_err(&pdev->dev, "%s: failed to allocate rds ring struct\n",
netdev->name);
goto err_out; goto err_out;
}
recv_ctx->rds_rings = rds_ring; recv_ctx->rds_rings = rds_ring;
for (ring = 0; ring < adapter->max_rds_rings; ring++) { for (ring = 0; ring < adapter->max_rds_rings; ring++) {

Просмотреть файл

@ -3176,11 +3176,8 @@ netxen_list_config_vlan_ip(struct netxen_adapter *adapter,
} }
cur = kzalloc(sizeof(struct nx_vlan_ip_list), GFP_ATOMIC); cur = kzalloc(sizeof(struct nx_vlan_ip_list), GFP_ATOMIC);
if (cur == NULL) { if (cur == NULL)
printk(KERN_ERR "%s: failed to add vlan ip to list\n",
adapter->netdev->name);
return; return;
}
cur->ip_addr = ifa->ifa_address; cur->ip_addr = ifa->ifa_address;
list_add_tail(&cur->list, &adapter->vlan_ip_list); list_add_tail(&cur->list, &adapter->vlan_ip_list);

Просмотреть файл

@ -2591,13 +2591,11 @@ static int ql_alloc_buffer_queues(struct ql3_adapter *qdev)
else else
qdev->lrg_buf_q_alloc_size = qdev->lrg_buf_q_size * 2; qdev->lrg_buf_q_alloc_size = qdev->lrg_buf_q_size * 2;
qdev->lrg_buf = qdev->lrg_buf = kmalloc_array(qdev->num_large_buffers,
kmalloc(qdev->num_large_buffers * sizeof(struct ql_rcv_buf_cb), sizeof(struct ql_rcv_buf_cb),
GFP_KERNEL); GFP_KERNEL);
if (qdev->lrg_buf == NULL) { if (qdev->lrg_buf == NULL)
netdev_err(qdev->ndev, "qdev->lrg_buf alloc failed\n");
return -ENOMEM; return -ENOMEM;
}
qdev->lrg_buf_q_alloc_virt_addr = qdev->lrg_buf_q_alloc_virt_addr =
pci_alloc_consistent(qdev->pdev, pci_alloc_consistent(qdev->pdev,

Просмотреть файл

@ -1171,12 +1171,9 @@ static int qlcnic_83xx_copy_bootloader(struct qlcnic_adapter *adapter)
size = (size + 16) & ~0xF; size = (size + 16) & ~0xF;
p_cache = kzalloc(size, GFP_KERNEL); p_cache = kzalloc(size, GFP_KERNEL);
if (p_cache == NULL)
if (p_cache == NULL) {
dev_err(&adapter->pdev->dev,
"Failed to allocate memory for boot loader cache\n");
return -ENOMEM; return -ENOMEM;
}
ret = qlcnic_83xx_lockless_flash_read32(adapter, src, p_cache, ret = qlcnic_83xx_lockless_flash_read32(adapter, src, p_cache,
size / sizeof(u32)); size / sizeof(u32));
if (ret) { if (ret) {
@ -1487,12 +1484,9 @@ int qlcnic_83xx_get_reset_instruction_template(struct qlcnic_adapter *p_dev)
ahw->reset.seq_error = 0; ahw->reset.seq_error = 0;
ahw->reset.buff = kzalloc(QLC_83XX_RESTART_TEMPLATE_SIZE, GFP_KERNEL); ahw->reset.buff = kzalloc(QLC_83XX_RESTART_TEMPLATE_SIZE, GFP_KERNEL);
if (p_dev->ahw->reset.buff == NULL)
if (p_dev->ahw->reset.buff == NULL) {
dev_err(&p_dev->pdev->dev,
"%s: resource allocation failed\n", __func__);
return -ENOMEM; return -ENOMEM;
}
p_buff = p_dev->ahw->reset.buff; p_buff = p_dev->ahw->reset.buff;
addr = QLC_83XX_RESET_TEMPLATE_ADDR; addr = QLC_83XX_RESET_TEMPLATE_ADDR;
count = sizeof(struct qlc_83xx_reset_hdr) / sizeof(u32); count = sizeof(struct qlc_83xx_reset_hdr) / sizeof(u32);

Просмотреть файл

@ -481,11 +481,9 @@ int qlcnic_nic_add_mac(struct qlcnic_adapter *adapter, const u8 *addr)
} }
cur = kzalloc(sizeof(struct qlcnic_mac_list_s), GFP_ATOMIC); cur = kzalloc(sizeof(struct qlcnic_mac_list_s), GFP_ATOMIC);
if (cur == NULL) { if (cur == NULL)
dev_err(&adapter->netdev->dev,
"failed to add mac address filter\n");
return -ENOMEM; return -ENOMEM;
}
memcpy(cur->mac_addr, addr, ETH_ALEN); memcpy(cur->mac_addr, addr, ETH_ALEN);
if (qlcnic_sre_macaddr_change(adapter, if (qlcnic_sre_macaddr_change(adapter,

Просмотреть файл

@ -184,18 +184,15 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter)
struct qlcnic_host_rds_ring *rds_ring; struct qlcnic_host_rds_ring *rds_ring;
struct qlcnic_host_sds_ring *sds_ring; struct qlcnic_host_sds_ring *sds_ring;
struct qlcnic_rx_buffer *rx_buf; struct qlcnic_rx_buffer *rx_buf;
int ring, i, size; int ring, i;
struct net_device *netdev = adapter->netdev;
recv_ctx = adapter->recv_ctx; recv_ctx = adapter->recv_ctx;
size = adapter->max_rds_rings * sizeof(struct qlcnic_host_rds_ring); rds_ring = kcalloc(adapter->max_rds_rings,
rds_ring = kzalloc(size, GFP_KERNEL); sizeof(struct qlcnic_host_rds_ring), GFP_KERNEL);
if (rds_ring == NULL) { if (rds_ring == NULL)
dev_err(&netdev->dev, "failed to allocate rds ring struct\n");
goto err_out; goto err_out;
}
recv_ctx->rds_rings = rds_ring; recv_ctx->rds_rings = rds_ring;
for (ring = 0; ring < adapter->max_rds_rings; ring++) { for (ring = 0; ring < adapter->max_rds_rings; ring++) {
@ -221,11 +218,8 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter)
break; break;
} }
rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring)); rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring));
if (rds_ring->rx_buf_arr == NULL) { if (rds_ring->rx_buf_arr == NULL)
dev_err(&netdev->dev,
"Failed to allocate rx buffer ring %d\n", ring);
goto err_out; goto err_out;
}
INIT_LIST_HEAD(&rds_ring->free_list); INIT_LIST_HEAD(&rds_ring->free_list);
/* /*
@ -448,10 +442,8 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter)
} }
buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL); buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
if (buf == NULL) { if (buf == NULL)
dev_err(&pdev->dev, "Unable to calloc memory for rom read.\n");
return -ENOMEM; return -ENOMEM;
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (qlcnic_rom_fast_read(adapter, 8*i + 4*offset, &val) != 0 || if (qlcnic_rom_fast_read(adapter, 8*i + 4*offset, &val) != 0 ||
@ -657,10 +649,8 @@ static int qlcnic_get_flt_entry(struct qlcnic_adapter *adapter, u8 region,
entry_size = flt_hdr.len - sizeof(struct qlcnic_flt_header); entry_size = flt_hdr.len - sizeof(struct qlcnic_flt_header);
flt_entry = vzalloc(entry_size); flt_entry = vzalloc(entry_size);
if (flt_entry == NULL) { if (flt_entry == NULL)
dev_warn(&adapter->pdev->dev, "error allocating memory\n");
return -EIO; return -EIO;
}
ret = qlcnic_rom_fast_read_words(adapter, QLCNIC_FLT_LOCATION + ret = qlcnic_rom_fast_read_words(adapter, QLCNIC_FLT_LOCATION +
sizeof(struct qlcnic_flt_header), sizeof(struct qlcnic_flt_header),

Просмотреть файл

@ -414,10 +414,8 @@ int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix)
adapter->msix_entries = kcalloc(num_msix, adapter->msix_entries = kcalloc(num_msix,
sizeof(struct msix_entry), sizeof(struct msix_entry),
GFP_KERNEL); GFP_KERNEL);
if (!adapter->msix_entries) { if (!adapter->msix_entries)
dev_err(&pdev->dev, "failed allocating msix_entries\n");
return -ENOMEM; return -ENOMEM;
}
} }
adapter->max_sds_rings = 1; adapter->max_sds_rings = 1;
@ -1536,8 +1534,6 @@ static int qlcnic_alloc_adapter_resources(struct qlcnic_adapter *adapter)
adapter->recv_ctx = kzalloc(sizeof(struct qlcnic_recv_context), adapter->recv_ctx = kzalloc(sizeof(struct qlcnic_recv_context),
GFP_KERNEL); GFP_KERNEL);
if (!adapter->recv_ctx) { if (!adapter->recv_ctx) {
dev_err(&adapter->pdev->dev,
"Failed to allocate recv ctx resources for adapter\n");
err = -ENOMEM; err = -ENOMEM;
goto err_out; goto err_out;
} }
@ -1764,16 +1760,15 @@ void qlcnic_free_tx_rings(struct qlcnic_adapter *adapter)
int qlcnic_alloc_tx_rings(struct qlcnic_adapter *adapter, int qlcnic_alloc_tx_rings(struct qlcnic_adapter *adapter,
struct net_device *netdev) struct net_device *netdev)
{ {
int ring, size, vector, index; int ring, vector, index;
struct qlcnic_host_tx_ring *tx_ring; struct qlcnic_host_tx_ring *tx_ring;
struct qlcnic_cmd_buffer *cmd_buf_arr; struct qlcnic_cmd_buffer *cmd_buf_arr;
size = adapter->max_drv_tx_rings * sizeof(struct qlcnic_host_tx_ring); tx_ring = kcalloc(adapter->max_drv_tx_rings,
tx_ring = kzalloc(size, GFP_KERNEL); sizeof(struct qlcnic_host_tx_ring), GFP_KERNEL);
if (tx_ring == NULL) { if (tx_ring == NULL)
dev_err(&netdev->dev, "failed to allocate tx rings\n");
return -ENOMEM; return -ENOMEM;
}
adapter->tx_ring = tx_ring; adapter->tx_ring = tx_ring;
for (ring = 0; ring < adapter->max_drv_tx_rings; ring++) { for (ring = 0; ring < adapter->max_drv_tx_rings; ring++) {
@ -1782,8 +1777,6 @@ int qlcnic_alloc_tx_rings(struct qlcnic_adapter *adapter,
tx_ring->txq = netdev_get_tx_queue(netdev, ring); tx_ring->txq = netdev_get_tx_queue(netdev, ring);
cmd_buf_arr = vzalloc(TX_BUFF_RINGSIZE(tx_ring)); cmd_buf_arr = vzalloc(TX_BUFF_RINGSIZE(tx_ring));
if (cmd_buf_arr == NULL) { if (cmd_buf_arr == NULL) {
dev_err(&netdev->dev,
"failed to allocate cmd buffer ring\n");
qlcnic_free_tx_rings(adapter); qlcnic_free_tx_rings(adapter);
return -ENOMEM; return -ENOMEM;
} }

Просмотреть файл

@ -931,12 +931,9 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
return -EIO; return -EIO;
fw_dump->data = vzalloc(dump_size); fw_dump->data = vzalloc(dump_size);
if (!fw_dump->data) { if (!fw_dump->data)
dev_info(&adapter->pdev->dev,
"Unable to allocate (%d KB) for fw dump\n",
dump_size / 1024);
return -ENOMEM; return -ENOMEM;
}
buffer = fw_dump->data; buffer = fw_dump->data;
fw_dump->size = dump_size; fw_dump->size = dump_size;
no_entries = tmpl_hdr->num_entries; no_entries = tmpl_hdr->num_entries;

Просмотреть файл

@ -4572,7 +4572,6 @@ static int ql_init_device(struct pci_dev *pdev, struct net_device *ndev,
qdev->mpi_coredump = qdev->mpi_coredump =
vmalloc(sizeof(struct ql_mpi_coredump)); vmalloc(sizeof(struct ql_mpi_coredump));
if (qdev->mpi_coredump == NULL) { if (qdev->mpi_coredump == NULL) {
dev_err(&pdev->dev, "Coredump alloc failed.\n");
err = -ENOMEM; err = -ENOMEM;
goto err_out2; goto err_out2;
} }

Просмотреть файл

@ -1192,9 +1192,8 @@ static int r6040_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
lp->mii_bus->name = "r6040_eth_mii"; lp->mii_bus->name = "r6040_eth_mii";
snprintf(lp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", snprintf(lp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
dev_name(&pdev->dev), card_idx); dev_name(&pdev->dev), card_idx);
lp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); lp->mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
if (!lp->mii_bus->irq) { if (!lp->mii_bus->irq) {
dev_err(&pdev->dev, "mii_bus irq allocation failed\n");
err = -ENOMEM; err = -ENOMEM;
goto err_out_mdio; goto err_out_mdio;
} }

Просмотреть файл

@ -891,18 +891,16 @@ static int sh_eth_ring_init(struct net_device *ndev)
mdp->rx_buf_sz += NET_IP_ALIGN; mdp->rx_buf_sz += NET_IP_ALIGN;
/* Allocate RX and TX skb rings */ /* Allocate RX and TX skb rings */
mdp->rx_skbuff = kmalloc(sizeof(*mdp->rx_skbuff) * mdp->num_rx_ring, mdp->rx_skbuff = kmalloc_array(mdp->num_rx_ring,
GFP_KERNEL); sizeof(*mdp->rx_skbuff), GFP_KERNEL);
if (!mdp->rx_skbuff) { if (!mdp->rx_skbuff) {
dev_err(&ndev->dev, "Cannot allocate Rx skb\n");
ret = -ENOMEM; ret = -ENOMEM;
return ret; return ret;
} }
mdp->tx_skbuff = kmalloc(sizeof(*mdp->tx_skbuff) * mdp->num_tx_ring, mdp->tx_skbuff = kmalloc_array(mdp->num_tx_ring,
GFP_KERNEL); sizeof(*mdp->tx_skbuff), GFP_KERNEL);
if (!mdp->tx_skbuff) { if (!mdp->tx_skbuff) {
dev_err(&ndev->dev, "Cannot allocate Tx skb\n");
ret = -ENOMEM; ret = -ENOMEM;
goto skb_ring_free; goto skb_ring_free;
} }

Просмотреть файл

@ -530,17 +530,18 @@ static void init_dma_desc_rings(struct net_device *dev)
DBG(probe, INFO, "stmmac: txsize %d, rxsize %d, bfsize %d\n", DBG(probe, INFO, "stmmac: txsize %d, rxsize %d, bfsize %d\n",
txsize, rxsize, bfsize); txsize, rxsize, bfsize);
priv->rx_skbuff_dma = kmalloc(rxsize * sizeof(dma_addr_t), GFP_KERNEL); priv->rx_skbuff_dma = kmalloc_array(rxsize, sizeof(dma_addr_t),
priv->rx_skbuff = GFP_KERNEL);
kmalloc(sizeof(struct sk_buff *) * rxsize, GFP_KERNEL); priv->rx_skbuff = kmalloc_array(rxsize, sizeof(struct sk_buff *),
GFP_KERNEL);
priv->dma_rx = priv->dma_rx =
(struct dma_desc *)dma_alloc_coherent(priv->device, (struct dma_desc *)dma_alloc_coherent(priv->device,
rxsize * rxsize *
sizeof(struct dma_desc), sizeof(struct dma_desc),
&priv->dma_rx_phy, &priv->dma_rx_phy,
GFP_KERNEL); GFP_KERNEL);
priv->tx_skbuff = kmalloc(sizeof(struct sk_buff *) * txsize, priv->tx_skbuff = kmalloc_array(txsize, sizeof(struct sk_buff *),
GFP_KERNEL); GFP_KERNEL);
priv->dma_tx = priv->dma_tx =
(struct dma_desc *)dma_alloc_coherent(priv->device, (struct dma_desc *)dma_alloc_coherent(priv->device,
txsize * txsize *

Просмотреть файл

@ -4342,7 +4342,7 @@ static int niu_alloc_rx_ring_info(struct niu *np,
{ {
BUILD_BUG_ON(sizeof(struct rxdma_mailbox) != 64); BUILD_BUG_ON(sizeof(struct rxdma_mailbox) != 64);
rp->rxhash = kzalloc(MAX_RBR_RING_SIZE * sizeof(struct page *), rp->rxhash = kcalloc(MAX_RBR_RING_SIZE, sizeof(struct page *),
GFP_KERNEL); GFP_KERNEL);
if (!rp->rxhash) if (!rp->rxhash)
return -ENOMEM; return -ENOMEM;

Просмотреть файл

@ -1061,12 +1061,10 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
} }
data->cpts_clock_shift = prop; data->cpts_clock_shift = prop;
data->slave_data = kzalloc(sizeof(struct cpsw_slave_data) * data->slave_data = kcalloc(data->slaves, sizeof(struct cpsw_slave_data),
data->slaves, GFP_KERNEL); GFP_KERNEL);
if (!data->slave_data) { if (!data->slave_data)
pr_err("Could not allocate slave memory.\n");
return -EINVAL; return -EINVAL;
}
if (of_property_read_u32(node, "cpdma_channels", &prop)) { if (of_property_read_u32(node, "cpdma_channels", &prop)) {
pr_err("Missing cpdma_channels property in the DT.\n"); pr_err("Missing cpdma_channels property in the DT.\n");

Просмотреть файл

@ -320,10 +320,8 @@ static int davinci_mdio_probe(struct platform_device *pdev)
int ret, addr; int ret, addr;
data = kzalloc(sizeof(*data), GFP_KERNEL); data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data) { if (!data)
dev_err(dev, "failed to alloc device data\n");
return -ENOMEM; return -ENOMEM;
}
data->bus = mdiobus_alloc(); data->bus = mdiobus_alloc();
if (!data->bus) { if (!data->bus) {

Просмотреть файл

@ -238,11 +238,9 @@ static int temac_dma_bd_init(struct net_device *ndev)
int i; int i;
lp->rx_skb = kcalloc(RX_BD_NUM, sizeof(*lp->rx_skb), GFP_KERNEL); lp->rx_skb = kcalloc(RX_BD_NUM, sizeof(*lp->rx_skb), GFP_KERNEL);
if (!lp->rx_skb) { if (!lp->rx_skb)
dev_err(&ndev->dev,
"can't allocate memory for DMA RX buffer\n");
goto out; goto out;
}
/* allocate the tx and rx ring buffer descriptors. */ /* allocate the tx and rx ring buffer descriptors. */
/* returns a virtual address and a physical address. */ /* returns a virtual address and a physical address. */
lp->tx_bd_v = dma_alloc_coherent(ndev->dev.parent, lp->tx_bd_v = dma_alloc_coherent(ndev->dev.parent,