Replace kmalloc+memset with kzalloc Patch 4/17 Signed-off-by: Yan Burman diff -rubp linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_ap.c linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_ap.c --- linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_ap.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_ap.c 2006-11-11 22:44:04.000000000 +0200 @@ -1100,14 +1100,13 @@ static struct sta_info * ap_add_sta(stru struct sta_info *sta; sta = (struct sta_info *) - kmalloc(sizeof(struct sta_info), GFP_ATOMIC); + kzalloc(sizeof(struct sta_info), GFP_ATOMIC); if (sta == NULL) { PDEBUG(DEBUG_AP, "AP: kmalloc failed\n"); return NULL; } /* initialize STA info data */ - memset(sta, 0, sizeof(struct sta_info)); sta->local = ap->local; skb_queue_head_init(&sta->tx_buf); memcpy(sta->addr, addr, ETH_ALEN); diff -rubp linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_cs.c linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_cs.c --- linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_cs.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_cs.c 2006-11-11 22:44:04.000000000 +0200 @@ -566,12 +566,11 @@ static int prism2_config(struct pcmcia_d PDEBUG(DEBUG_FLOW, "prism2_config()\n"); parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL); - hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); + hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); if (parse == NULL || hw_priv == NULL) { ret = -ENOMEM; goto failed; } - memset(hw_priv, 0, sizeof(*hw_priv)); tuple.DesiredTuple = CISTPL_CONFIG; tuple.Attributes = 0; diff -rubp linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_download.c linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_download.c --- linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_download.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_download.c 2006-11-11 22:44:04.000000000 +0200 @@ -685,14 +685,12 @@ static int prism2_download(local_info_t goto out; } - dl = kmalloc(sizeof(*dl) + param->num_areas * + dl = kzalloc(sizeof(*dl) + param->num_areas * sizeof(struct prism2_download_data_area), GFP_KERNEL); if (dl == NULL) { ret = -ENOMEM; goto out; } - memset(dl, 0, sizeof(*dl) + param->num_areas * - sizeof(struct prism2_download_data_area)); dl->dl_cmd = param->dl_cmd; dl->start_addr = param->start_addr; dl->num_areas = param->num_areas; diff -rubp linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_hw.c linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_hw.c --- linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_hw.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_hw.c 2006-11-11 22:44:04.000000000 +0200 @@ -348,13 +348,12 @@ static int hfa384x_cmd(struct net_device return -EINTR; entry = (struct hostap_cmd_queue *) - kmalloc(sizeof(*entry), GFP_ATOMIC); + kzalloc(sizeof(*entry), GFP_ATOMIC); if (entry == NULL) { printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n", dev->name); return -ENOMEM; } - memset(entry, 0, sizeof(*entry)); atomic_set(&entry->usecnt, 1); entry->type = CMD_SLEEP; entry->cmd = cmd; @@ -518,13 +517,12 @@ static int hfa384x_cmd_callback(struct n } entry = (struct hostap_cmd_queue *) - kmalloc(sizeof(*entry), GFP_ATOMIC); + kzalloc(sizeof(*entry), GFP_ATOMIC); if (entry == NULL) { printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc " "failed\n", dev->name); return -ENOMEM; } - memset(entry, 0, sizeof(*entry)); atomic_set(&entry->usecnt, 1); entry->type = CMD_CALLBACK; entry->cmd = cmd; @@ -3016,13 +3014,12 @@ static int prism2_set_tim(struct net_dev local = iface->local; new_entry = (struct set_tim_data *) - kmalloc(sizeof(*new_entry), GFP_ATOMIC); + kzalloc(sizeof(*new_entry), GFP_ATOMIC); if (new_entry == NULL) { printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n", local->dev->name); return -ENOMEM; } - memset(new_entry, 0, sizeof(*new_entry)); new_entry->aid = aid; new_entry->set = set; diff -rubp linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_info.c linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_info.c --- linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_info.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_info.c 2006-11-11 22:44:04.000000000 +0200 @@ -327,11 +327,10 @@ static void prism2_info_hostscanresults( ptr = (u8 *) pos; new_count = left / result_size; - results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result), + results = kzalloc(new_count * sizeof(struct hfa384x_hostscan_result), GFP_ATOMIC); if (results == NULL) return; - memset(results, 0, new_count * sizeof(struct hfa384x_hostscan_result)); for (i = 0; i < new_count; i++) { memcpy(&results[i], ptr, copy_len); diff -rubp linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_ioctl.c linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_ioctl.c --- linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_ioctl.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_ioctl.c 2006-11-11 22:44:04.000000000 +0200 @@ -182,11 +182,10 @@ static int prism2_ioctl_siwencode(struct /* take WEP into use */ new_crypt = (struct ieee80211_crypt_data *) - kmalloc(sizeof(struct ieee80211_crypt_data), + kzalloc(sizeof(struct ieee80211_crypt_data), GFP_KERNEL); if (new_crypt == NULL) return -ENOMEM; - memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); new_crypt->ops = ieee80211_get_crypto_ops("WEP"); if (!new_crypt->ops) { request_module("ieee80211_crypt_wep"); @@ -3321,13 +3320,12 @@ static int prism2_ioctl_siwencodeext(str prism2_crypt_delayed_deinit(local, crypt); new_crypt = (struct ieee80211_crypt_data *) - kmalloc(sizeof(struct ieee80211_crypt_data), + kzalloc(sizeof(struct ieee80211_crypt_data), GFP_KERNEL); if (new_crypt == NULL) { ret = -ENOMEM; goto done; } - memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); new_crypt->ops = ops; new_crypt->priv = new_crypt->ops->init(i); if (new_crypt->priv == NULL) { @@ -3539,13 +3537,12 @@ static int prism2_ioctl_set_encryption(l prism2_crypt_delayed_deinit(local, crypt); new_crypt = (struct ieee80211_crypt_data *) - kmalloc(sizeof(struct ieee80211_crypt_data), + kzalloc(sizeof(struct ieee80211_crypt_data), GFP_KERNEL); if (new_crypt == NULL) { ret = -ENOMEM; goto done; } - memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); new_crypt->ops = ops; new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx); if (new_crypt->priv == NULL) { diff -rubp linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_pci.c linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_pci.c --- linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_pci.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_pci.c 2006-11-11 22:44:04.000000000 +0200 @@ -300,10 +300,9 @@ static int prism2_pci_probe(struct pci_d struct hostap_interface *iface; struct hostap_pci_priv *hw_priv; - hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); + hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); if (hw_priv == NULL) return -ENOMEM; - memset(hw_priv, 0, sizeof(*hw_priv)); if (pci_enable_device(pdev)) goto err_out_free; diff -rubp linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_plx.c linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_plx.c --- linux-2.6.19-rc5_orig/drivers/net/wireless/hostap/hostap_plx.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/drivers/net/wireless/hostap/hostap_plx.c 2006-11-11 22:44:04.000000000 +0200 @@ -447,10 +447,9 @@ static int prism2_plx_probe(struct pci_d int tmd7160; struct hostap_plx_priv *hw_priv; - hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); + hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); if (hw_priv == NULL) return -ENOMEM; - memset(hw_priv, 0, sizeof(*hw_priv)); if (pci_enable_device(pdev)) goto err_out_free; diff -rubp linux-2.6.19-rc5_orig/drivers/net/wireless/ipw2200.c linux-2.6.19-rc5_kzalloc/drivers/net/wireless/ipw2200.c --- linux-2.6.19-rc5_orig/drivers/net/wireless/ipw2200.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/drivers/net/wireless/ipw2200.c 2006-11-11 22:44:04.000000000 +0200 @@ -11129,14 +11129,13 @@ static int ipw_up(struct ipw_priv *priv) return -EIO; if (cmdlog && !priv->cmdlog) { - priv->cmdlog = kmalloc(sizeof(*priv->cmdlog) * cmdlog, + priv->cmdlog = kzalloc(sizeof(*priv->cmdlog) * cmdlog, GFP_KERNEL); if (priv->cmdlog == NULL) { IPW_ERROR("Error allocating %d command log entries.\n", cmdlog); return -ENOMEM; } else { - memset(priv->cmdlog, 0, sizeof(*priv->cmdlog) * cmdlog); priv->cmdlog_len = cmdlog; } } diff -rubp linux-2.6.19-rc5_orig/drivers/net/wireless/prism54/isl_ioctl.c linux-2.6.19-rc5_kzalloc/drivers/net/wireless/prism54/isl_ioctl.c --- linux-2.6.19-rc5_orig/drivers/net/wireless/prism54/isl_ioctl.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/drivers/net/wireless/prism54/isl_ioctl.c 2006-11-11 22:44:04.000000000 +0200 @@ -2141,11 +2141,9 @@ prism54_wpa_bss_ie_add(islpci_private *p struct islpci_bss_wpa_ie, list); list_del(&bss->list); } else { - bss = kmalloc(sizeof (*bss), GFP_ATOMIC); - if (bss != NULL) { + bss = kzalloc(sizeof (*bss), GFP_ATOMIC); + if (bss != NULL) priv->num_bss_wpa++; - memset(bss, 0, sizeof (*bss)); - } } if (bss != NULL) { memcpy(bss->bssid, bssid, ETH_ALEN); @@ -2685,11 +2683,10 @@ prism2_ioctl_set_generic_element(struct return -EINVAL; alen = sizeof(*attach) + len; - attach = kmalloc(alen, GFP_KERNEL); + attach = kzalloc(alen, GFP_KERNEL); if (attach == NULL) return -ENOMEM; - memset(attach, 0, alen); #define WLAN_FC_TYPE_MGMT 0 #define WLAN_FC_STYPE_ASSOC_REQ 0 #define WLAN_FC_STYPE_REASSOC_REQ 2 diff -rubp linux-2.6.19-rc5_orig/drivers/net/wireless/prism54/oid_mgt.c linux-2.6.19-rc5_kzalloc/drivers/net/wireless/prism54/oid_mgt.c --- linux-2.6.19-rc5_orig/drivers/net/wireless/prism54/oid_mgt.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/drivers/net/wireless/prism54/oid_mgt.c 2006-11-11 22:44:04.000000000 +0200 @@ -235,12 +235,10 @@ mgt_init(islpci_private *priv) { int i; - priv->mib = kmalloc(OID_NUM_LAST * sizeof (void *), GFP_KERNEL); + priv->mib = kzalloc(OID_NUM_LAST * sizeof (void *), GFP_KERNEL); if (!priv->mib) return -ENOMEM; - memset(priv->mib, 0, OID_NUM_LAST * sizeof (void *)); - /* Alloc the cache */ for (i = 0; i < OID_NUM_LAST; i++) { if (isl_oid[i].flags & OID_FLAG_CACHED) { diff -rubp linux-2.6.19-rc5_orig/drivers/net/wireless/zd1201.c linux-2.6.19-rc5_kzalloc/drivers/net/wireless/zd1201.c --- linux-2.6.19-rc5_orig/drivers/net/wireless/zd1201.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/drivers/net/wireless/zd1201.c 2006-11-11 22:44:18.000000000 +0200 @@ -524,7 +524,7 @@ static int zd1201_setconfig(struct zd120 zd->rxdatas = 0; zd->rxlen = 0; for (seq=0; len > 0; seq++) { - request = kmalloc(16, gfp_mask); + request = kzalloc(16, gfp_mask); if (!request) return -ENOMEM; urb = usb_alloc_urb(0, gfp_mask); @@ -532,7 +532,6 @@ static int zd1201_setconfig(struct zd120 kfree(request); return -ENOMEM; } - memset(request, 0, 16); reqlen = len>12 ? 12 : len; request[0] = ZD1201_USB_RESREQ; request[1] = seq; diff -rubp linux-2.6.19-rc5_orig/net/ieee80211/ieee80211_module.c linux-2.6.19-rc5_kzalloc/net/ieee80211/ieee80211_module.c --- linux-2.6.19-rc5_orig/net/ieee80211/ieee80211_module.c 2006-11-09 12:16:21.000000000 +0200 +++ linux-2.6.19-rc5_kzalloc/net/ieee80211/ieee80211_module.c 2006-11-11 22:44:18.000000000 +0200 @@ -67,7 +67,7 @@ static int ieee80211_networks_allocate(s return 0; ieee->networks = - kmalloc(MAX_NETWORK_COUNT * sizeof(struct ieee80211_network), + kzalloc(MAX_NETWORK_COUNT * sizeof(struct ieee80211_network), GFP_KERNEL); if (!ieee->networks) { printk(KERN_WARNING "%s: Out of memory allocating beacons\n", @@ -75,9 +75,6 @@ static int ieee80211_networks_allocate(s return -ENOMEM; } - memset(ieee->networks, 0, - MAX_NETWORK_COUNT * sizeof(struct ieee80211_network)); - return 0; }