ethernet: Remove unnecessary alloc/OOM messages, alloc cleanups
authorJoe Perches <joe@perches.com>
Sun, 3 Feb 2013 17:43:58 +0000 (17:43 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 4 Feb 2013 18:22:33 +0000 (13:22 -0500)
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>
38 files changed:
drivers/net/ethernet/atheros/atl1c/atl1c_main.c
drivers/net/ethernet/atheros/atl1e/atl1e_main.c
drivers/net/ethernet/broadcom/b44.c
drivers/net/ethernet/broadcom/bcm63xx_enet.c
drivers/net/ethernet/broadcom/cnic.c
drivers/net/ethernet/broadcom/tg3.c
drivers/net/ethernet/freescale/gianfar_ethtool.c
drivers/net/ethernet/ibm/ehea/ehea_main.c
drivers/net/ethernet/ibm/ehea/ehea_qmr.c
drivers/net/ethernet/ibm/emac/mal.c
drivers/net/ethernet/ibm/ibmveth.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/igbvf/netdev.c
drivers/net/ethernet/marvell/mv643xx_eth.c
drivers/net/ethernet/marvell/mvmdio.c
drivers/net/ethernet/marvell/skge.c
drivers/net/ethernet/marvell/sky2.c
drivers/net/ethernet/mellanox/mlx4/en_main.c
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/myricom/myri10ge/myri10ge.c
drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
drivers/net/ethernet/qlogic/qla3xxx.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
drivers/net/ethernet/qlogic/qlge/qlge_main.c
drivers/net/ethernet/rdc/r6040.c
drivers/net/ethernet/renesas/sh_eth.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/sun/niu.c
drivers/net/ethernet/ti/cpsw.c
drivers/net/ethernet/ti/davinci_mdio.c
drivers/net/ethernet/xilinx/ll_temac_main.c

index 8df02ba2ce46fbda01d0c43539b26b8565a33db3..571b5145c079b24ddbb7c4e826ad533ce55f6af5 100644 (file)
@@ -982,11 +982,9 @@ static int atl1c_setup_ring_resources(struct atl1c_adapter *adapter)
        size = sizeof(struct atl1c_buffer) * (tpd_ring->count * 2 +
                rfd_ring->count);
        tpd_ring->buffer_info = kzalloc(size, GFP_KERNEL);
-       if (unlikely(!tpd_ring->buffer_info)) {
-               dev_err(&pdev->dev, "kzalloc failed, size = %d\n",
-                       size);
+       if (unlikely(!tpd_ring->buffer_info))
                goto err_nomem;
-       }
+
        for (i = 0; i < AT_MAX_TRANSMIT_QUEUE; i++) {
                tpd_ring[i].buffer_info =
                        (tpd_ring->buffer_info + count);
index cf79d932fa3570512a208514ce9638bd947f7500..92f4734f860d3f18ece977946b4562c028df35e6 100644 (file)
@@ -819,8 +819,6 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
        size = sizeof(struct atl1e_tx_buffer) * (tx_ring->count);
        tx_ring->tx_buffer = kzalloc(size, GFP_KERNEL);
        if (tx_ring->tx_buffer == NULL) {
-               netdev_err(adapter->netdev, "kzalloc failed, size = D%d\n",
-                          size);
                err = -ENOMEM;
                goto failed;
        }
index 3ba6be689e7dff8a40ce3368d2b4b0fa39de7772..c030274a70ab5d8288128d14814438295feec8d4 100644 (file)
@@ -1518,10 +1518,8 @@ static void b44_setup_pseudo_magicp(struct b44 *bp)
        u8 pwol_mask[B44_PMASK_SIZE];
 
        pwol_pattern = kzalloc(B44_PATTERN_SIZE, GFP_KERNEL);
-       if (!pwol_pattern) {
-               pr_err("Memory not available for WOL\n");
+       if (!pwol_pattern)
                return;
-       }
 
        /* Ipv4 magic packet pattern - pattern 0.*/
        memset(pwol_mask, 0, B44_PMASK_SIZE);
index f5b6b4715d455c167717ae94521f4bdc6b7bf369..7d81e059e811356b4621ec89df7e52eb56cbf15d 100644 (file)
@@ -886,10 +886,9 @@ static int bcm_enet_open(struct net_device *dev)
        priv->tx_desc_alloc_size = size;
        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);
        if (!priv->tx_skb) {
-               dev_err(kdev, "cannot allocate rx skb queue\n");
                ret = -ENOMEM;
                goto out_free_tx_ring;
        }
@@ -900,10 +899,9 @@ static int bcm_enet_open(struct net_device *dev)
        spin_lock_init(&priv->tx_lock);
 
        /* 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);
        if (!priv->rx_skb) {
-               dev_err(kdev, "cannot allocate rx skb queue\n");
                ret = -ENOMEM;
                goto out_free_tx_skb;
        }
index 1c4dadc7ebbb75bdd9b76ec4264ea9c8e4280f7f..149a3a03849113732f7ea805fc1f660b98a94a62 100644 (file)
@@ -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);
 
-       cdev = kzalloc(alloc_size , GFP_KERNEL);
-       if (cdev == NULL) {
-               netdev_err(dev, "allocate dev struct failure\n");
+       cdev = kzalloc(alloc_size, GFP_KERNEL);
+       if (cdev == NULL)
                return NULL;
-       }
 
        cdev->netdev = dev;
        cdev->cnic_priv = (char *)cdev + sizeof(struct cnic_dev);
index ab07026a36e310cb9790928490cd1f104512f4ac..90195e324a64a122990d109914643133030ffc4b 100644 (file)
@@ -5793,10 +5793,8 @@ static void tg3_dump_state(struct tg3 *tp)
        u32 *regs;
 
        regs = kzalloc(TG3_REG_BLK_SIZE, GFP_ATOMIC);
-       if (!regs) {
-               netdev_err(tp->dev, "Failed allocating register dump buffer\n");
+       if (!regs)
                return;
-       }
 
        if (tg3_flag(tp, PCI_EXPRESS)) {
                /* Read up to but not including private PCI registers */
index d0fe53c5b297b0efdfa982d2af63691afa4260da..45e59d5c071f33ba0685d45683f4474293229d7f 100644 (file)
@@ -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 ret = 1;
 
-       local_rqfpr = kmalloc(sizeof(unsigned int) * (MAX_FILER_IDX + 1),
-                             GFP_KERNEL);
-       local_rqfcr = kmalloc(sizeof(unsigned int) * (MAX_FILER_IDX + 1),
-                             GFP_KERNEL);
+       local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
+                                   GFP_KERNEL);
+       local_rqfcr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
+                                   GFP_KERNEL);
        if (!local_rqfpr || !local_rqfcr) {
-               pr_err("Out of memory\n");
                ret = 0;
                goto err;
        }
index 19b64de7124b9ae51e0649b887bc1b208c7627b3..91977d9c1b460a6afa6da68496b5930c56a9b380 100644 (file)
@@ -1921,10 +1921,8 @@ static void ehea_add_multicast_entry(struct ehea_port *port, u8 *mc_mac_addr)
        u64 hret;
 
        ehea_mcl_entry = kzalloc(sizeof(*ehea_mcl_entry), GFP_ATOMIC);
-       if (!ehea_mcl_entry) {
-               pr_err("no mem for mcl_entry\n");
+       if (!ehea_mcl_entry)
                return;
-       }
 
        INIT_LIST_HEAD(&ehea_mcl_entry->list);
 
index 27f881758d16c541560d616b22efc16649389241..9b03033bb5576f52d7c6f687f9e1a99c8e7a21a5 100644 (file)
@@ -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_pages = kmalloc(nr_of_pages * sizeof(void *), GFP_KERNEL);
-       if (!queue->queue_pages) {
-               pr_err("no mem for queue_pages\n");
+       queue->queue_pages = kmalloc_array(nr_of_pages, sizeof(void *),
+                                          GFP_KERNEL);
+       if (!queue->queue_pages)
                return -ENOMEM;
-       }
 
        /*
         * allocate pages for queue:
@@ -129,10 +128,8 @@ struct ehea_cq *ehea_create_cq(struct ehea_adapter *adapter,
        void *vpage;
 
        cq = kzalloc(sizeof(*cq), GFP_KERNEL);
-       if (!cq) {
-               pr_err("no mem for cq\n");
+       if (!cq)
                goto out_nomem;
-       }
 
        cq->attr.max_nr_of_cqes = nr_of_cqe;
        cq->attr.cq_token = cq_token;
@@ -257,10 +254,8 @@ struct ehea_eq *ehea_create_eq(struct ehea_adapter *adapter,
        struct ehea_eq *eq;
 
        eq = kzalloc(sizeof(*eq), GFP_KERNEL);
-       if (!eq) {
-               pr_err("no mem for eq\n");
+       if (!eq)
                return NULL;
-       }
 
        eq->adapter = adapter;
        eq->attr.type = type;
@@ -428,10 +423,8 @@ struct ehea_qp *ehea_create_qp(struct ehea_adapter *adapter,
 
 
        qp = kzalloc(sizeof(*qp), GFP_KERNEL);
-       if (!qp) {
-               pr_err("no mem for qp\n");
+       if (!qp)
                return NULL;
-       }
 
        qp->adapter = adapter;
 
index 50ea12bfb579ebe47fd2d58ed082810e6e513cfa..1f7ecf57181e291d62f4567581169a5b52244ddd 100644 (file)
@@ -528,12 +528,9 @@ static int mal_probe(struct platform_device *ofdev)
        irq_handler_t hdlr_serr, hdlr_txde, hdlr_rxde;
 
        mal = kzalloc(sizeof(struct mal_instance), GFP_KERNEL);
-       if (!mal) {
-               printk(KERN_ERR
-                      "mal%d: out of memory allocating MAL structure!\n",
-                      index);
+       if (!mal)
                return -ENOMEM;
-       }
+
        mal->index = index;
        mal->ofdev = ofdev;
        mal->version = of_device_is_compatible(ofdev->dev.of_node, "ibm,mcmal2") ? 2 : 1;
index 4181f6e99c0003ba6f2ed1ae2055e0365dbd8e29..c859771a9902e21e2f5e03a7c0901c06788e6172 100644 (file)
@@ -637,7 +637,6 @@ static int ibmveth_open(struct net_device *netdev)
        adapter->bounce_buffer =
            kmalloc(netdev->mtu + IBMVETH_BUFF_OH, GFP_KERNEL);
        if (!adapter->bounce_buffer) {
-               netdev_err(netdev, "unable to allocate bounce buffer\n");
                rc = -ENOMEM;
                goto err_out_free_irq;
        }
index a59e63040f316052ef47c40ec2b21f825591680c..1aaf19351863e2f8db625518080f8b0e3e7d0641 100644 (file)
@@ -2671,9 +2671,8 @@ static int igb_sw_init(struct igb_adapter *adapter)
        igb_init_queue_configuration(adapter);
 
        /* Setup and initialize a copy of the hw vlan table array */
-       adapter->shadow_vfta = kzalloc(sizeof(u32) *
-                               E1000_VLAN_FILTER_TBL_SIZE,
-                               GFP_ATOMIC);
+       adapter->shadow_vfta = kcalloc(E1000_VLAN_FILTER_TBL_SIZE, sizeof(u32),
+                                      GFP_ATOMIC);
 
        /* This call may decrease the number of queues */
        if (igb_init_interrupt_scheme(adapter, true)) {
index 8224889e6845aa61488a4613adb8e5f9e649712f..f53f7136e508955ab7a16f4131a2818111de03c8 100644 (file)
@@ -1399,12 +1399,10 @@ static void igbvf_set_multi(struct net_device *netdev)
        int i;
 
        if (!netdev_mc_empty(netdev)) {
-               mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC);
-               if (!mta_list) {
-                       dev_err(&adapter->pdev->dev,
-                               "failed to allocate multicast filter list\n");
+               mta_list = kmalloc_array(netdev_mc_count(netdev), ETH_ALEN,
+                                        GFP_ATOMIC);
+               if (!mta_list)
                        return;
-               }
        }
 
        /* prepare a packed array of only addresses. */
index c27b23d8f4fc29bee16017ed29eda6ea3bc09507..29140502b71aea8765a917f2b68e34d8d645b249 100644 (file)
@@ -1879,12 +1879,10 @@ static int rxq_init(struct mv643xx_eth_private *mp, int index)
        memset(rxq->rx_desc_area, 0, size);
 
        rxq->rx_desc_area_size = size;
-       rxq->rx_skb = kmalloc(rxq->rx_ring_size * sizeof(*rxq->rx_skb),
-                                                               GFP_KERNEL);
-       if (rxq->rx_skb == NULL) {
-               netdev_err(mp->dev, "can't allocate rx skb ring\n");
+       rxq->rx_skb = kmalloc_array(rxq->rx_ring_size, sizeof(*rxq->rx_skb),
+                                   GFP_KERNEL);
+       if (rxq->rx_skb == NULL)
                goto out_free;
-       }
 
        rx_desc = rxq->rx_desc_area;
        for (i = 0; i < rxq->rx_ring_size; i++) {
index 74f1c157a4803311a61d2cddd4b1b4e4ece9ac1d..77b7c80262f4501867aea6b2be8520fc60f34a0d 100644 (file)
@@ -164,7 +164,6 @@ static int orion_mdio_probe(struct platform_device *pdev)
 
        bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
        if (!bus->irq) {
-               dev_err(&pdev->dev, "Cannot allocate PHY IRQ array\n");
                mdiobus_free(bus);
                return -ENOMEM;
        }
index 8b08bc4b8a76a747401e05044fc18fac380f040c..171f4b3dda07ae5fc4f9986c36102beeab8de49e 100644 (file)
@@ -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 */
        hw = kzalloc(sizeof(*hw) + strlen(DRV_NAME "@pci:")
                     + strlen(pci_name(pdev)) + 1, GFP_KERNEL);
-       if (!hw) {
-               dev_err(&pdev->dev, "cannot allocate hardware struct\n");
+       if (!hw)
                goto err_out_free_regions;
-       }
+
        sprintf(hw->irq_name, DRV_NAME "@pci:%s", pci_name(pdev));
 
        hw->pdev = pdev;
index 366a12aa3c74336c51affd951963194ec3ebe713..fc07ca35721b29ba07dba97bf6e52dc74f446534 100644 (file)
@@ -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:")
                     + strlen(pci_name(pdev)) + 1, GFP_KERNEL);
-       if (!hw) {
-               dev_err(&pdev->dev, "cannot allocate hardware struct\n");
+       if (!hw)
                goto err_out_free_regions;
-       }
 
        hw->pdev = pdev;
        sprintf(hw->irq_name, DRV_NAME "@pci:%s", pci_name(pdev));
index 3a2b8c65642dd7566ffbccfbbcc0f479ee3d49f2..f3c7961a271fa598c7f66a46bc90ad639c22f02e 100644 (file)
@@ -191,10 +191,8 @@ static void *mlx4_en_add(struct mlx4_dev *dev)
 
        printk_once(KERN_INFO "%s", mlx4_en_version);
 
-       mdev = kzalloc(sizeof *mdev, GFP_KERNEL);
+       mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
        if (!mdev) {
-               dev_err(&dev->pdev->dev, "Device struct alloc failed, "
-                       "aborting.\n");
                err = -ENOMEM;
                goto err_free_res;
        }
index e38c6b2e157817852f211ed51385bf1d50cf48ea..12ddae6efce3c3f6e809d2d9bfda0a270e537302 100644 (file)
@@ -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 */
        dma_set_max_seg_size(&pdev->dev, 1024 * 1024 * 1024);
 
-       priv = kzalloc(sizeof *priv, GFP_KERNEL);
+       priv = kzalloc(sizeof(*priv), GFP_KERNEL);
        if (!priv) {
-               dev_err(&pdev->dev, "Device struct alloc failed, "
-                       "aborting.\n");
                err = -ENOMEM;
                goto err_release_regions;
        }
index f8408d6e961cb7243b6d2f862701697c47532d49..4f9937e026e5f9ca57cb99c2d969f3a12cc3dae2 100644 (file)
@@ -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
         * validate firmware */
        hdr = kmalloc(bytes, GFP_KERNEL);
-       if (hdr == NULL) {
-               dev_err(dev, "could not malloc firmware hdr\n");
+       if (hdr == NULL)
                return -ENOMEM;
-       }
+
        memcpy_fromio(hdr, mgp->sram + hdr_offset, bytes);
        status = myri10ge_validate_firmware(mgp, hdr);
        kfree(hdr);
index 7f556a84925d5677c6b87dd3e1cb72678c634243..1bcaf45aa8641f5302dde03a5a432dac3a71a799 100644 (file)
@@ -201,11 +201,8 @@ netxen_setup_minidump(struct netxen_adapter *adapter)
        adapter->mdump.md_template =
                kmalloc(adapter->mdump.md_template_size, GFP_KERNEL);
 
-       if (!adapter->mdump.md_template) {
-               dev_err(&adapter->pdev->dev, "Unable to allocate memory "
-                       "for minidump template.\n");
+       if (!adapter->mdump.md_template)
                return -ENOMEM;
-       }
 
        err = netxen_get_minidump_template(adapter);
        if (err) {
index 946160fa5843fd9b07f16d09253e7ce65c05ddef..9fbb1cdbfa4764b48d010f5ca43a851b33234e20 100644 (file)
@@ -670,11 +670,9 @@ static int nx_p3_nic_add_mac(struct netxen_adapter *adapter,
        }
 
        cur = kzalloc(sizeof(nx_mac_list_t), GFP_ATOMIC);
-       if (cur == NULL) {
-               printk(KERN_ERR "%s: failed to add mac address filter\n",
-                               adapter->netdev->name);
+       if (cur == NULL)
                return -ENOMEM;
-       }
+
        memcpy(cur->mac_addr, addr, ETH_ALEN);
        list_add_tail(&cur->list, &adapter->mac_list);
        return nx_p3_sre_macaddr_change(adapter,
@@ -2568,16 +2566,10 @@ netxen_dump_fw(struct netxen_adapter *adapter)
                                        adapter->mdump.md_capture_size;
        if (!adapter->mdump.md_capture_buff) {
                adapter->mdump.md_capture_buff =
-                               vmalloc(adapter->mdump.md_dump_size);
-               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);
+                               vzalloc(adapter->mdump.md_dump_size);
+               if (!adapter->mdump.md_capture_buff)
                        return;
-               }
-               memset(adapter->mdump.md_capture_buff, 0,
-                               adapter->mdump.md_dump_size);
+
                if (netxen_collect_minidump(adapter)) {
                        adapter->mdump.has_valid_dump = 0;
                        adapter->mdump.md_dump_size = 0;
index 695667d471a1bef8dc81dd8034a593a118993e07..db50598006efd1a9f081da5be3b8cc19ed425ad1 100644 (file)
@@ -197,41 +197,34 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
        struct nx_host_sds_ring *sds_ring;
        struct nx_host_tx_ring *tx_ring;
        struct netxen_rx_buffer *rx_buf;
-       int ring, i, size;
+       int ring, i;
 
        struct netxen_cmd_buffer *cmd_buf_arr;
        struct net_device *netdev = adapter->netdev;
        struct pci_dev *pdev = adapter->pdev;
 
-       size = sizeof(struct nx_host_tx_ring);
-       tx_ring = kzalloc(size, GFP_KERNEL);
-       if (tx_ring == NULL) {
-               dev_err(&pdev->dev, "%s: failed to allocate tx ring struct\n",
-                      netdev->name);
+       tx_ring = kzalloc(sizeof(struct nx_host_tx_ring), GFP_KERNEL);
+       if (tx_ring == NULL)
                return -ENOMEM;
-       }
+
        adapter->tx_ring = tx_ring;
 
        tx_ring->num_desc = adapter->num_txd;
        tx_ring->txq = netdev_get_tx_queue(netdev, 0);
 
        cmd_buf_arr = vzalloc(TX_BUFF_RINGSIZE(tx_ring));
-       if (cmd_buf_arr == NULL) {
-               dev_err(&pdev->dev, "%s: failed to allocate cmd buffer ring\n",
-                      netdev->name);
+       if (cmd_buf_arr == NULL)
                goto err_out;
-       }
+
        tx_ring->cmd_buf_arr = cmd_buf_arr;
 
        recv_ctx = &adapter->recv_ctx;
 
-       size = adapter->max_rds_rings * sizeof (struct nx_host_rds_ring);
-       rds_ring = kzalloc(size, GFP_KERNEL);
-       if (rds_ring == NULL) {
-               dev_err(&pdev->dev, "%s: failed to allocate rds ring struct\n",
-                      netdev->name);
+       rds_ring = kcalloc(adapter->max_rds_rings,
+                          sizeof(struct nx_host_rds_ring), GFP_KERNEL);
+       if (rds_ring == NULL)
                goto err_out;
-       }
+
        recv_ctx->rds_rings = rds_ring;
 
        for (ring = 0; ring < adapter->max_rds_rings; ring++) {
index 7a849fc55a6674a3879699ca73ef99756d824fa8..501f49207da5d635826fdcc41652fbc4868230bd 100644 (file)
@@ -3176,11 +3176,8 @@ netxen_list_config_vlan_ip(struct netxen_adapter *adapter,
                }
 
                cur = kzalloc(sizeof(struct nx_vlan_ip_list), GFP_ATOMIC);
-               if (cur == NULL) {
-                       printk(KERN_ERR "%s: failed to add vlan ip to list\n",
-                                       adapter->netdev->name);
+               if (cur == NULL)
                        return;
-               }
 
                cur->ip_addr = ifa->ifa_address;
                list_add_tail(&cur->list, &adapter->vlan_ip_list);
index c0ed12d325b462865a6a6914a1e0b6f197b576cd..8fd38cb6d26a54c502ab10d3250c781859a30801 100644 (file)
@@ -2591,13 +2591,11 @@ static int ql_alloc_buffer_queues(struct ql3_adapter *qdev)
        else
                qdev->lrg_buf_q_alloc_size = qdev->lrg_buf_q_size * 2;
 
-       qdev->lrg_buf =
-               kmalloc(qdev->num_large_buffers * sizeof(struct ql_rcv_buf_cb),
-                       GFP_KERNEL);
-       if (qdev->lrg_buf == NULL) {
-               netdev_err(qdev->ndev, "qdev->lrg_buf alloc failed\n");
+       qdev->lrg_buf = kmalloc_array(qdev->num_large_buffers,
+                                     sizeof(struct ql_rcv_buf_cb),
+                                     GFP_KERNEL);
+       if (qdev->lrg_buf == NULL)
                return -ENOMEM;
-       }
 
        qdev->lrg_buf_q_alloc_virt_addr =
                pci_alloc_consistent(qdev->pdev,
index c9e24a8c6787e10ed6cfae10a4f4ff9aaf1aa549..8163e5b338e43672b1dae511ccc90473c230b1d1 100644 (file)
@@ -1171,12 +1171,9 @@ static int qlcnic_83xx_copy_bootloader(struct qlcnic_adapter *adapter)
                size = (size + 16) & ~0xF;
 
        p_cache = kzalloc(size, GFP_KERNEL);
-
-       if (p_cache == NULL) {
-               dev_err(&adapter->pdev->dev,
-                       "Failed to allocate memory for boot loader cache\n");
+       if (p_cache == NULL)
                return -ENOMEM;
-       }
+
        ret = qlcnic_83xx_lockless_flash_read32(adapter, src, p_cache,
                                                size / sizeof(u32));
        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.buff = kzalloc(QLC_83XX_RESTART_TEMPLATE_SIZE, GFP_KERNEL);
-
-       if (p_dev->ahw->reset.buff == NULL) {
-               dev_err(&p_dev->pdev->dev,
-                       "%s: resource allocation failed\n", __func__);
+       if (p_dev->ahw->reset.buff == NULL)
                return -ENOMEM;
-       }
+
        p_buff = p_dev->ahw->reset.buff;
        addr = QLC_83XX_RESET_TEMPLATE_ADDR;
        count = sizeof(struct qlc_83xx_reset_hdr) / sizeof(u32);
index 88a2330c9572ea43c8070c3efc99ca053c0e723d..4ee92b254fc077ceab9fb689a086bdb6aacf5c1d 100644 (file)
@@ -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);
-       if (cur == NULL) {
-               dev_err(&adapter->netdev->dev,
-                       "failed to add mac address filter\n");
+       if (cur == NULL)
                return -ENOMEM;
-       }
+
        memcpy(cur->mac_addr, addr, ETH_ALEN);
 
        if (qlcnic_sre_macaddr_change(adapter,
index aa71ebaefdc0d3271e59f9a5dbaa4a820eaa659e..10ad25d7aa0ed8647e7f1c37d4482f43971a4ad9 100644 (file)
@@ -184,18 +184,15 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter)
        struct qlcnic_host_rds_ring *rds_ring;
        struct qlcnic_host_sds_ring *sds_ring;
        struct qlcnic_rx_buffer *rx_buf;
-       int ring, i, size;
-
-       struct net_device *netdev = adapter->netdev;
+       int ring, i;
 
        recv_ctx = adapter->recv_ctx;
 
-       size = adapter->max_rds_rings * sizeof(struct qlcnic_host_rds_ring);
-       rds_ring = kzalloc(size, GFP_KERNEL);
-       if (rds_ring == NULL) {
-               dev_err(&netdev->dev, "failed to allocate rds ring struct\n");
+       rds_ring = kcalloc(adapter->max_rds_rings,
+                          sizeof(struct qlcnic_host_rds_ring), GFP_KERNEL);
+       if (rds_ring == NULL)
                goto err_out;
-       }
+
        recv_ctx->rds_rings = rds_ring;
 
        for (ring = 0; ring < adapter->max_rds_rings; ring++) {
@@ -221,11 +218,8 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter)
                        break;
                }
                rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring));
-               if (rds_ring->rx_buf_arr == NULL) {
-                       dev_err(&netdev->dev,
-                               "Failed to allocate rx buffer ring %d\n", ring);
+               if (rds_ring->rx_buf_arr == NULL)
                        goto err_out;
-               }
 
                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);
-       if (buf == NULL) {
-               dev_err(&pdev->dev, "Unable to calloc memory for rom read.\n");
+       if (buf == NULL)
                return -ENOMEM;
-       }
 
        for (i = 0; i < n; i++) {
                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);
        flt_entry = vzalloc(entry_size);
-       if (flt_entry == NULL) {
-               dev_warn(&adapter->pdev->dev, "error allocating memory\n");
+       if (flt_entry == NULL)
                return -EIO;
-       }
 
        ret = qlcnic_rom_fast_read_words(adapter, QLCNIC_FLT_LOCATION +
                                         sizeof(struct qlcnic_flt_header),
index 6a59a115c4d3606609394d1ca4ccdb47eb2b0309..fb0255a90ce49367834c0838205579d58b892648 100644 (file)
@@ -414,10 +414,8 @@ int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix)
                adapter->msix_entries = kcalloc(num_msix,
                                                sizeof(struct msix_entry),
                                                GFP_KERNEL);
-               if (!adapter->msix_entries) {
-                       dev_err(&pdev->dev, "failed allocating msix_entries\n");
+               if (!adapter->msix_entries)
                        return -ENOMEM;
-               }
        }
 
        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),
                                GFP_KERNEL);
        if (!adapter->recv_ctx) {
-               dev_err(&adapter->pdev->dev,
-                       "Failed to allocate recv ctx resources for adapter\n");
                err = -ENOMEM;
                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,
                          struct net_device *netdev)
 {
-       int ring, size, vector, index;
+       int ring, vector, index;
        struct qlcnic_host_tx_ring *tx_ring;
        struct qlcnic_cmd_buffer *cmd_buf_arr;
 
-       size = adapter->max_drv_tx_rings * sizeof(struct qlcnic_host_tx_ring);
-       tx_ring = kzalloc(size, GFP_KERNEL);
-       if (tx_ring == NULL) {
-               dev_err(&netdev->dev, "failed to allocate tx rings\n");
+       tx_ring = kcalloc(adapter->max_drv_tx_rings,
+                         sizeof(struct qlcnic_host_tx_ring), GFP_KERNEL);
+       if (tx_ring == NULL)
                return -ENOMEM;
-       }
+
        adapter->tx_ring = tx_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);
                cmd_buf_arr = vzalloc(TX_BUFF_RINGSIZE(tx_ring));
                if (cmd_buf_arr == NULL) {
-                       dev_err(&netdev->dev,
-                               "failed to allocate cmd buffer ring\n");
                        qlcnic_free_tx_rings(adapter);
                        return -ENOMEM;
                }
index 6281cbd1a654844a0d694f1c118f04f0bf15ce0f..8dbc8e76bc7414e21e19e7054e23267c60f85e1f 100644 (file)
@@ -931,12 +931,9 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
                return -EIO;
 
        fw_dump->data = vzalloc(dump_size);
-       if (!fw_dump->data) {
-               dev_info(&adapter->pdev->dev,
-                        "Unable to allocate (%d KB) for fw dump\n",
-                        dump_size / 1024);
+       if (!fw_dump->data)
                return -ENOMEM;
-       }
+
        buffer = fw_dump->data;
        fw_dump->size = dump_size;
        no_entries = tmpl_hdr->num_entries;
index e9381584e4b3ae390010696cf2118bb0263a307b..325627e287fc7d91d4074cdcc6b9a3c1644b68b3 100644 (file)
@@ -4572,7 +4572,6 @@ static int ql_init_device(struct pci_dev *pdev, struct net_device *ndev,
                qdev->mpi_coredump =
                        vmalloc(sizeof(struct ql_mpi_coredump));
                if (qdev->mpi_coredump == NULL) {
-                       dev_err(&pdev->dev, "Coredump alloc failed.\n");
                        err = -ENOMEM;
                        goto err_out2;
                }
index 34f76e99dc8ac4f0ca1029c82030e8f0791d07cd..5b4103db70f5c25025241672c19e48be6c583eaa 100644 (file)
@@ -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";
        snprintf(lp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
                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) {
-               dev_err(&pdev->dev, "mii_bus irq allocation failed\n");
                err = -ENOMEM;
                goto err_out_mdio;
        }
index e195c1e89d6164670eae151bd9bec99b0951e3fe..33e96176e4d82167a2d62a51f1f1eb5d711f7375 100644 (file)
@@ -891,18 +891,16 @@ static int sh_eth_ring_init(struct net_device *ndev)
                mdp->rx_buf_sz += NET_IP_ALIGN;
 
        /* Allocate RX and TX skb rings */
-       mdp->rx_skbuff = kmalloc(sizeof(*mdp->rx_skbuff) * mdp->num_rx_ring,
-                               GFP_KERNEL);
+       mdp->rx_skbuff = kmalloc_array(mdp->num_rx_ring,
+                                      sizeof(*mdp->rx_skbuff), GFP_KERNEL);
        if (!mdp->rx_skbuff) {
-               dev_err(&ndev->dev, "Cannot allocate Rx skb\n");
                ret = -ENOMEM;
                return ret;
        }
 
-       mdp->tx_skbuff = kmalloc(sizeof(*mdp->tx_skbuff) * mdp->num_tx_ring,
-                               GFP_KERNEL);
+       mdp->tx_skbuff = kmalloc_array(mdp->num_tx_ring,
+                                      sizeof(*mdp->tx_skbuff), GFP_KERNEL);
        if (!mdp->tx_skbuff) {
-               dev_err(&ndev->dev, "Cannot allocate Tx skb\n");
                ret = -ENOMEM;
                goto skb_ring_free;
        }
index 8c657294ce565d71e2fdc23e6af16a649dc7da4d..fd4d659f0fac8d73fca8ff528a397b0a0bb6448e 100644 (file)
@@ -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",
            txsize, rxsize, bfsize);
 
-       priv->rx_skbuff_dma = kmalloc(rxsize * sizeof(dma_addr_t), GFP_KERNEL);
-       priv->rx_skbuff =
-           kmalloc(sizeof(struct sk_buff *) * rxsize, GFP_KERNEL);
+       priv->rx_skbuff_dma = kmalloc_array(rxsize, sizeof(dma_addr_t),
+                                           GFP_KERNEL);
+       priv->rx_skbuff = kmalloc_array(rxsize, sizeof(struct sk_buff *),
+                                       GFP_KERNEL);
        priv->dma_rx =
            (struct dma_desc *)dma_alloc_coherent(priv->device,
                                                  rxsize *
                                                  sizeof(struct dma_desc),
                                                  &priv->dma_rx_phy,
                                                  GFP_KERNEL);
-       priv->tx_skbuff = kmalloc(sizeof(struct sk_buff *) * txsize,
-                                      GFP_KERNEL);
+       priv->tx_skbuff = kmalloc_array(txsize, sizeof(struct sk_buff *),
+                                       GFP_KERNEL);
        priv->dma_tx =
            (struct dma_desc *)dma_alloc_coherent(priv->device,
                                                  txsize *
index c8c491564f9ddf70b942b01a6b40f2346fe68f41..e4c1c88e4c2af4b8faf8f0db5f964baa48167647 100644 (file)
@@ -4342,7 +4342,7 @@ static int niu_alloc_rx_ring_info(struct niu *np,
 {
        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);
        if (!rp->rxhash)
                return -ENOMEM;
index b35e6a76664cec1882ad7c552c43524a3973f9c6..9e63bff124fedd1a456af60407cb529017dda96e 100644 (file)
@@ -1061,12 +1061,10 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
        }
        data->cpts_clock_shift = prop;
 
-       data->slave_data = kzalloc(sizeof(struct cpsw_slave_data) *
-                                  data->slaves, GFP_KERNEL);
-       if (!data->slave_data) {
-               pr_err("Could not allocate slave memory.\n");
+       data->slave_data = kcalloc(data->slaves, sizeof(struct cpsw_slave_data),
+                                  GFP_KERNEL);
+       if (!data->slave_data)
                return -EINVAL;
-       }
 
        if (of_property_read_u32(node, "cpdma_channels", &prop)) {
                pr_err("Missing cpdma_channels property in the DT.\n");
index cca25509b0392113c7c6f359836ba837607dbd96..d04a622b08d4f798ee12f30ab1cd35ecead2701b 100644 (file)
@@ -320,10 +320,8 @@ static int davinci_mdio_probe(struct platform_device *pdev)
        int ret, addr;
 
        data = kzalloc(sizeof(*data), GFP_KERNEL);
-       if (!data) {
-               dev_err(dev, "failed to alloc device data\n");
+       if (!data)
                return -ENOMEM;
-       }
 
        data->bus = mdiobus_alloc();
        if (!data->bus) {
index 5022093286f043a3e918e6dac105c9bb36d8e115..9fc2ada4c3c2f22b001021264564ceca323f62ea 100644 (file)
@@ -238,11 +238,9 @@ static int temac_dma_bd_init(struct net_device *ndev)
        int i;
 
        lp->rx_skb = kcalloc(RX_BD_NUM, sizeof(*lp->rx_skb), GFP_KERNEL);
-       if (!lp->rx_skb) {
-               dev_err(&ndev->dev,
-                               "can't allocate memory for DMA RX buffer\n");
+       if (!lp->rx_skb)
                goto out;
-       }
+
        /* allocate the tx and rx ring buffer descriptors. */
        /* returns a virtual address and a physical address. */
        lp->tx_bd_v = dma_alloc_coherent(ndev->dev.parent,