/* Allocate space for private device-specific data */
        local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
-       if (!local) {
-               printk(KERN_ERR "airo_cs: no memory for new device\n");
+       if (!local)
                return -ENOMEM;
-       }
+
        p_dev->priv = local;
 
        return airo_config(p_dev);
 
 
        buffer_size = sizeof(struct at76_tx_buffer) + MAX_PADDING_SIZE;
        priv->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
-       if (!priv->bulk_out_buffer) {
-               dev_err(&interface->dev, "cannot allocate output buffer\n");
+       if (!priv->bulk_out_buffer)
                return -ENOMEM;
-       }
 
        at76_dbg(DBG_PROC_ENTRY, "%s: EXIT", __func__);
 
 
 dfs_pattern_detector_init(enum nl80211_dfs_regions region)
 {
        struct dfs_pattern_detector *dpd;
+
        dpd = kmalloc(sizeof(*dpd), GFP_KERNEL);
-       if (dpd == NULL) {
-               pr_err("allocation of dfs_pattern_detector failed\n");
+       if (dpd == NULL)
                return NULL;
-       }
+
        *dpd = default_dpd;
        INIT_LIST_HEAD(&dpd->channel_detectors);
 
 
 
        /* Allocate space for private device-specific data */
        local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
-       if (!local) {
-               printk(KERN_ERR "atmel_cs: no memory for new device\n");
+       if (!local)
                return -ENOMEM;
-       }
+
        p_dev->priv = local;
 
        return atmel_config(p_dev);
 
                return err;
        }
 
-       priv->tx_buffers =
-           kmalloc(TX_PENDED_QUEUE_LENGTH * sizeof(struct ipw2100_tx_packet),
-                   GFP_ATOMIC);
+       priv->tx_buffers = kmalloc_array(TX_PENDED_QUEUE_LENGTH,
+                                        sizeof(struct ipw2100_tx_packet),
+                                        GFP_ATOMIC);
        if (!priv->tx_buffers) {
-               printk(KERN_ERR DRV_NAME
-                      ": %s: alloc failed form tx buffers.\n",
-                      priv->net_dev->name);
                bd_queue_free(priv, &priv->tx_queue);
                return -ENOMEM;
        }
 
        lbs_deb_enter(LBS_DEB_CFG80211);
 
        wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
-       if (!wdev) {
-               dev_err(dev, "cannot allocate wireless device\n");
+       if (!wdev)
                return ERR_PTR(-ENOMEM);
-       }
 
        wdev->wiphy = wiphy_new(&lbs_cfg80211_ops, sizeof(struct lbs_private));
        if (!wdev->wiphy) {
 
        if (!mwifiex_get_ba_tbl(priv, tid, ra)) {
                new_node = kzalloc(sizeof(struct mwifiex_tx_ba_stream_tbl),
                                   GFP_ATOMIC);
-               if (!new_node) {
-                       dev_err(priv->adapter->dev,
-                               "%s: failed to alloc new_node\n", __func__);
+               if (!new_node)
                        return;
-               }
 
                INIT_LIST_HEAD(&new_node->list);
 
 
        }
        /* if !tbl then create one */
        new_node = kzalloc(sizeof(struct mwifiex_rx_reorder_tbl), GFP_KERNEL);
-       if (!new_node) {
-               dev_err(priv->adapter->dev, "%s: failed to alloc new_node\n",
-                       __func__);
+       if (!new_node)
                return;
-       }
 
        INIT_LIST_HEAD(&new_node->list);
        new_node->tid = tid;
 
 
        priv->user_scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg),
                                      GFP_KERNEL);
-       if (!priv->user_scan_cfg) {
-               dev_err(priv->adapter->dev, "failed to alloc scan_req\n");
+       if (!priv->user_scan_cfg)
                return -ENOMEM;
-       }
 
        priv->scan_request = request;
 
 
 int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter)
 {
        struct cmd_ctrl_node *cmd_array;
-       u32 buf_size;
        u32 i;
 
        /* Allocate and initialize struct cmd_ctrl_node */
-       buf_size = sizeof(struct cmd_ctrl_node) * MWIFIEX_NUM_OF_CMD_BUFFER;
-       cmd_array = kzalloc(buf_size, GFP_KERNEL);
-       if (!cmd_array) {
-               dev_err(adapter->dev, "%s: failed to alloc cmd_array\n",
-                       __func__);
+       cmd_array = kcalloc(MWIFIEX_NUM_OF_CMD_BUFFER,
+                           sizeof(struct cmd_ctrl_node), GFP_KERNEL);
+       if (!cmd_array)
                return -ENOMEM;
-       }
 
        adapter->cmd_pool = cmd_array;
-       memset(adapter->cmd_pool, 0, buf_size);
 
        /* Allocate and initialize command buffers */
        for (i = 0; i < MWIFIEX_NUM_OF_CMD_BUFFER; i++) {
 
        unsigned long flags;
 
        bss_prio = kzalloc(sizeof(struct mwifiex_bss_prio_node), GFP_KERNEL);
-       if (!bss_prio) {
-               dev_err(adapter->dev, "%s: failed to alloc bss_prio\n",
-                       __func__);
+       if (!bss_prio)
                return -ENOMEM;
-       }
 
        bss_prio->priv = priv;
        INIT_LIST_HEAD(&bss_prio->list);
 
        struct cmd_ctrl_node *cmd_node;
        union mwifiex_scan_cmd_config_tlv *scan_cfg_out;
        struct mwifiex_ie_types_chan_list_param_set *chan_list_out;
-       u32 buf_size;
        struct mwifiex_chan_scan_param_set *scan_chan_list;
        u8 filtered_scan;
        u8 scan_current_chan_only;
        spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
 
        scan_cfg_out = kzalloc(sizeof(union mwifiex_scan_cmd_config_tlv),
-                                                               GFP_KERNEL);
+                              GFP_KERNEL);
        if (!scan_cfg_out) {
-               dev_err(adapter->dev, "failed to alloc scan_cfg_out\n");
                ret = -ENOMEM;
                goto done;
        }
 
-       buf_size = sizeof(struct mwifiex_chan_scan_param_set) *
-                                               MWIFIEX_USER_SCAN_CHAN_MAX;
-       scan_chan_list = kzalloc(buf_size, GFP_KERNEL);
+       scan_chan_list = kcalloc(MWIFIEX_USER_SCAN_CHAN_MAX,
+                                sizeof(struct mwifiex_chan_scan_param_set),
+                                GFP_KERNEL);
        if (!scan_chan_list) {
-               dev_err(adapter->dev, "failed to alloc scan_chan_list\n");
                kfree(scan_cfg_out);
                ret = -ENOMEM;
                goto done;
        unsigned long flags;
 
        /* Allocate and fill new bss descriptor */
-       bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor),
-                       GFP_KERNEL);
-       if (!bss_desc) {
-               dev_err(priv->adapter->dev, " failed to alloc bss_desc\n");
+       bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor), GFP_KERNEL);
+       if (!bss_desc)
                return -ENOMEM;
-       }
 
        ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc);
        if (ret)
        }
 
        scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg), GFP_KERNEL);
-       if (!scan_cfg) {
-               dev_err(adapter->dev, "failed to alloc scan_cfg\n");
+       if (!scan_cfg)
                return -ENOMEM;
-       }
 
        scan_cfg->ssid_list = req_ssid;
        scan_cfg->num_ssids = 1;
                kfree(priv->curr_bcn_buf);
                priv->curr_bcn_buf = kmalloc(curr_bss->beacon_buf_size,
                                             GFP_ATOMIC);
-               if (!priv->curr_bcn_buf) {
-                       dev_err(priv->adapter->dev,
-                               "failed to alloc curr_bcn_buf\n");
+               if (!priv->curr_bcn_buf)
                        return;
-               }
        }
 
        memcpy(priv->curr_bcn_buf, curr_bss->beacon_buf,
 
 
        /* Assume that the allocated buffer is 8-byte aligned */
        fwbuf = kzalloc(MWIFIEX_UPLD_SIZE, GFP_KERNEL);
-       if (!fwbuf) {
-               dev_err(adapter->dev,
-                       "unable to alloc buffer for FW. Terminating dnld\n");
+       if (!fwbuf)
                return -ENOMEM;
-       }
 
        /* Perform firmware data transfer */
        do {
 
        card->mpa_tx.buf = kzalloc(mpa_tx_buf_size, GFP_KERNEL);
        if (!card->mpa_tx.buf) {
-               dev_err(adapter->dev, "could not alloc buffer for MP-A TX\n");
                ret = -1;
                goto error;
        }
 
        card->mpa_rx.buf = kzalloc(mpa_rx_buf_size, GFP_KERNEL);
        if (!card->mpa_rx.buf) {
-               dev_err(adapter->dev, "could not alloc buffer for MP-A RX\n");
                ret = -1;
                goto error;
        }
 
        /* Allocate buffers for SDIO MP-A */
        card->mp_regs = kzalloc(MAX_MP_REGS, GFP_KERNEL);
-       if (!card->mp_regs) {
-               dev_err(adapter->dev, "failed to alloc mp_regs\n");
+       if (!card->mp_regs)
                return -ENOMEM;
-       }
 
        ret = mwifiex_alloc_sdio_mpa_buffers(adapter,
                                             SDIO_MP_TX_AGGR_DEF_BUF_SIZE,
 
 
                /* Allocate and fill new bss descriptor */
                bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor),
-                               GFP_KERNEL);
-               if (!bss_desc) {
-                       dev_err(priv->adapter->dev, " failed to alloc bss_desc\n");
+                                  GFP_KERNEL);
+               if (!bss_desc)
                        return -ENOMEM;
-               }
 
                ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc);
                if (ret)
                }
        }
        buf = kzalloc(MWIFIEX_SIZE_OF_CMD_BUFFER, GFP_KERNEL);
-       if (!buf) {
-               dev_err(priv->adapter->dev, "%s: failed to alloc cmd buffer\n",
-                       __func__);
+       if (!buf)
                return -ENOMEM;
-       }
 
        txp_cfg = (struct host_cmd_ds_txpwr_cfg *) buf;
        txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET);
 
        struct mwifiex_ra_list_tbl *ra_list;
 
        ra_list = kzalloc(sizeof(struct mwifiex_ra_list_tbl), GFP_ATOMIC);
-
-       if (!ra_list) {
-               dev_err(adapter->dev, "%s: failed to alloc ra_list\n",
-                       __func__);
+       if (!ra_list)
                return NULL;
-       }
+
        INIT_LIST_HEAD(&ra_list->list);
        skb_queue_head_init(&ra_list->skb_head);
 
 
        int err;
 
        desc = kmalloc(sizeof(*desc), GFP_ATOMIC);
-       if (!desc) {
-               printk(KERN_WARNING
-                      "%s: Can't allocate space for RX descriptor\n",
-                      dev->name);
+       if (!desc)
                goto update_stats;
-       }
 
        rxfid = hermes_read_regn(hw, RXFID);
 
        unsigned long flags;
 
        sd = kmalloc(sizeof(*sd), GFP_ATOMIC);
-       if (!sd) {
-               printk(KERN_ERR "%s: failed to alloc memory\n", __func__);
+       if (!sd)
                return;
-       }
+
        sd->buf = buf;
        sd->len = len;
        sd->type = type;
        unsigned long flags;
 
        sd = kmalloc(sizeof(*sd), GFP_ATOMIC);
-       if (!sd) {
-               printk(KERN_ERR "%s: failed to alloc memory\n", __func__);
+       if (!sd)
                return;
-       }
+
        sd->len = -1; /* Abort */
 
        spin_lock_irqsave(&priv->scan_lock, flags);
 
                return err;
 
        tmp = buf = kmalloc(P54U_FW_BLOCK, GFP_KERNEL);
-       if (!buf) {
-               dev_err(&priv->udev->dev, "(p54usb) cannot allocate firmware"
-                                         "upload buffer!\n");
+       if (!buf)
                return -ENOMEM;
-       }
 
        left = block_size = min((size_t)P54U_FW_BLOCK, priv->fw->size);
        strcpy(buf, p54u_firmware_upload_3887);
        const u8 *data;
 
        buf = kmalloc(512, GFP_KERNEL);
-       if (!buf) {
-               dev_err(&priv->udev->dev, "(p54usb) firmware buffer "
-                                         "alloc failed!\n");
+       if (!buf)
                return -ENOMEM;
-       }
 
 #define P54U_WRITE(type, addr, data) \
        do {\
 
 
                if (buf->mem == NULL) {
                        buf->mem = kmalloc(MGMT_FRAME_SIZE, GFP_ATOMIC);
-                       if (!buf->mem) {
-                               printk(KERN_WARNING
-                                      "Error allocating management frame.\n");
+                       if (!buf->mem)
                                return -ENOMEM;
-                       }
                        buf->size = MGMT_FRAME_SIZE;
                }
                if (buf->pci_addr == 0) {
 
                /* Determine frame size, skipping OID_INL_TUNNEL headers. */
                size = PIMFOR_HEADER_SIZE + header->length;
-               frame = kmalloc(sizeof (struct islpci_mgmtframe) + size,
+               frame = kmalloc(sizeof(struct islpci_mgmtframe) + size,
                                GFP_ATOMIC);
-               if (!frame) {
-                       printk(KERN_WARNING
-                              "%s: Out of memory, cannot handle oid 0x%08x\n",
-                              ndev->name, header->oid);
+               if (!frame)
                        continue;
-               }
+
                frame->ndev = ndev;
                memcpy(&frame->buf, header, size);
                frame->header = (pimfor_header_t *) frame->buf;
 
        } else if (mc_count) {
                int i = 0;
 
-               mc_addrs = kmalloc(mc_count * ETH_ALEN, GFP_ATOMIC);
+               mc_addrs = kmalloc_array(mc_count, ETH_ALEN, GFP_ATOMIC);
                if (!mc_addrs) {
-                       netdev_warn(usbdev->net,
-                                   "couldn't alloc %d bytes of memory\n",
-                                   mc_count * ETH_ALEN);
                        netif_addr_unlock_bh(usbdev->net);
                        return;
                }
 
                return -ENODEV;
 
        glue = kzalloc(sizeof(*glue), GFP_KERNEL);
-       if (!glue) {
-               dev_err(&func->dev, "can't allocate glue\n");
+       if (!glue)
                goto out;
-       }
 
        glue->dev = &func->dev;
 
 
        struct spi_message m;
 
        cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL);
-       if (!cmd) {
-               dev_err(child->parent,
-                       "could not allocate cmd for spi reset\n");
+       if (!cmd)
                return;
-       }
 
        memset(&t, 0, sizeof(t));
        spi_message_init(&m);
        struct spi_message m;
 
        cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL);
-       if (!cmd) {
-               dev_err(child->parent,
-                       "could not allocate cmd for spi init\n");
+       if (!cmd)
                return;
-       }
 
        memset(crc, 0, sizeof(crc));
        memset(&t, 0, sizeof(t));
        pdata->ops = &spi_ops;
 
        glue = kzalloc(sizeof(*glue), GFP_KERNEL);
-       if (!glue) {
-               dev_err(&spi->dev, "can't allocate glue\n");
+       if (!glue)
                goto out;
-       }
 
        glue->dev = &spi->dev;
 
 
         */
        p = kmalloc(MAX_TRANSFER_SIZE, GFP_KERNEL);
        if (!p) {
-               dev_err(&udev->dev, "out of memory\n");
                r = -ENOMEM;
                goto error;
        }