imamnurby/smpl_train_seed8 huggingface dataset:
--- initial
+++ final
@@ -1,32 +1,31 @@
 static void subsys_create_adapter(struct hpi_message *phm, struct hpi_response *phr) {
   /* create temp adapter obj, because we don't know what index yet */
   struct hpi_adapter_obj ao;
   u32 os_error_code;
   u16 err;
   HPI_DEBUG_LOG(DEBUG, " subsys_create_adapter\n");
   memset(&ao, 0, sizeof(ao));
   /* this HPI only creates adapters for TI/PCI devices */
   if (phm->u.s.resource.bus_type != HPI_BUS_PCI) return;
   if (phm->u.s.resource.r.pci->vendor_id != HPI_PCI_VENDOR_ID_TI) return;
   if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_DSP6205) return;
-  ao.priv = kmalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL);
+  ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL);
   if (!ao.priv) {
     HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n");
     phr->error = HPI_ERROR_MEMORY_ALLOC;
     return;
   }
-  memset(ao.priv, 0, sizeof(struct hpi_hw_obj));
   ao.pci = *phm->u.s.resource.r.pci;
   err = create_adapter_obj(&ao, &os_error_code);
   if (!err) err = hpi_add_adapter(&ao);
   if (err) {
     phr->u.s.data = os_error_code;
     delete_adapter_obj(&ao);
     phr->error = err;
     return;
   }
   phr->u.s.aw_adapter_list[ao.index] = ao.adapter_type;
   phr->u.s.adapter_index = ao.index;
   phr->u.s.num_adapters++;
   phr->error = 0;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,17 +1,16 @@
 struct fb_info *framebuffer_alloc(size_t size, struct device *dev) {
 #define BYTES_PER_LONG (BITS_PER_LONG / 8)
 #define PADDING (BYTES_PER_LONG - (sizeof(struct fb_info) % BYTES_PER_LONG))
   int fb_info_size = sizeof(struct fb_info);
   struct fb_info *info;
   char *p;
   if (size) fb_info_size += PADDING;
-  p = kmalloc(fb_info_size + size, GFP_KERNEL);
+  p = kzalloc(fb_info_size + size, GFP_KERNEL);
   if (!p) return NULL;
-  memset(p, 0, fb_info_size + size);
   info = (struct fb_info *)p;
   if (size) info->par = p + fb_info_size;
   info->device = dev;
   return info;
 #undef PADDING
 #undef BYTES_PER_LONG
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,10 +1,9 @@
 static int h4_open(struct hci_uart *hu) {
   struct h4_struct *h4;
   BT_DBG("hu %p", hu);
-  h4 = kmalloc(sizeof(*h4), GFP_ATOMIC);
+  h4 = kzalloc(sizeof(*h4), GFP_ATOMIC);
   if (!h4) return -ENOMEM;
-  memset(h4, 0, sizeof(*h4));
   skb_queue_head_init(&h4->txq);
   hu->priv = h4;
   return 0;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,49 +1,46 @@
 MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, const char *name, void *context) {
   MYPROCOBJECT *obj = NULL, *rc = NULL;
   int i = 0;
   if (type == NULL) FAIL("type cannot be NULL", 0);
-  obj = kmalloc(sizeof(MYPROCOBJECT), GFP_KERNEL | __GFP_NORETRY);
+  obj = kzalloc(sizeof(MYPROCOBJECT), GFP_KERNEL | __GFP_NORETRY);
   if (obj == NULL) FAIL("out of memory", 0);
-  memset(obj, 0, sizeof(MYPROCOBJECT));
   obj->type = type;
   obj->context = context;
   if (name == NULL) {
     obj->name = NULL;
     obj->procDir = type->procDir;
   } else {
     obj->namesize = strlen(name) + 1;
     obj->name = kmalloc(obj->namesize, GFP_KERNEL | __GFP_NORETRY);
     if (obj->name == NULL) {
       obj->namesize = 0;
       FAIL("out of memory", 0);
     }
     strcpy(obj->name, name);
     obj->procDir = createProcDir(obj->name, type->procDir);
     if (obj->procDir == NULL) RETPTR(NULL);
   }
-  obj->procDirPropertyContexts = kmalloc((type->nProperties + 1) * sizeof(PROCDIRENTRYCONTEXT), GFP_KERNEL | __GFP_NORETRY);
+  obj->procDirPropertyContexts = kzalloc((type->nProperties + 1) * sizeof(PROCDIRENTRYCONTEXT), GFP_KERNEL | __GFP_NORETRY);
   if (obj->procDirPropertyContexts == NULL) FAIL("out of memory", 0);
-  memset(obj->procDirPropertyContexts, 0, (type->nProperties + 1) * sizeof(PROCDIRENTRYCONTEXT));
-  obj->procDirProperties = kmalloc((type->nProperties + 1) * sizeof(struct proc_dir_entry *), GFP_KERNEL | __GFP_NORETRY);
+  obj->procDirProperties = kzalloc((type->nProperties + 1) * sizeof(struct proc_dir_entry *), GFP_KERNEL | __GFP_NORETRY);
   if (obj->procDirProperties == NULL) FAIL("out of memory", 0);
-  memset(obj->procDirProperties, 0, (type->nProperties + 1) * sizeof(struct proc_dir_entry *));
   for (i = 0; i < type->nProperties; i++) {
     obj->procDirPropertyContexts[i].procObject = obj;
     obj->procDirPropertyContexts[i].propertyIndex = i;
     obj->procDirPropertyContexts[i].show_property = type->show_property;
     if (type->propertyNames[i][0] != '\0') {
       /* only create properties that have names */
       obj->procDirProperties[i] = createProcFile(type->propertyNames[i], obj->procDir, &proc_fops, &obj->procDirPropertyContexts[i]);
       if (obj->procDirProperties[i] == NULL) RETPTR(NULL);
     }
   }
   RETPTR(obj);
 Away:
   if (rc == NULL) {
     if (obj != NULL) {
       visor_proc_DestroyObject(obj);
       obj = NULL;
     }
   }
   return rc;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,71 +1,70 @@
 static int matroxfb_probe(struct pci_dev *pdev, const struct pci_device_id *dummy) {
   struct board *b;
   u_int16_t svid;
   u_int16_t sid;
   struct matrox_fb_info *minfo;
   int err;
   u_int32_t cmd;
   DBG(__func__)
   svid = pdev->subsystem_vendor;
   sid = pdev->subsystem_device;
   for (b = dev_list; b->vendor; b++) {
     if ((b->vendor != pdev->vendor) || (b->device != pdev->device) || (b->rev < pdev->revision)) continue;
     if (b->svid)
       if ((b->svid != svid) || (b->sid != sid)) continue;
     break;
   }
   /* not match... */
   if (!b->vendor) return -ENODEV;
   if (dev > 0) {
     /* not requested one... */
     dev--;
     return -ENODEV;
   }
   pci_read_config_dword(pdev, PCI_COMMAND, &cmd);
   if (pci_enable_device(pdev)) { return -1; }
-  minfo = kmalloc(sizeof(*minfo), GFP_KERNEL);
+  minfo = kzalloc(sizeof(*minfo), GFP_KERNEL);
   if (!minfo) return -1;
-  memset(minfo, 0, sizeof(*minfo));
   minfo->pcidev = pdev;
   minfo->dead = 0;
   minfo->usecount = 0;
   minfo->userusecount = 0;
   pci_set_drvdata(pdev, minfo);
   /* DEVFLAGS */
   minfo->devflags.memtype = memtype;
   if (memtype != -1) noinit = 0;
   if (cmd & PCI_COMMAND_MEMORY) {
     minfo->devflags.novga = novga;
     minfo->devflags.nobios = nobios;
     minfo->devflags.noinit = noinit;
     /* subsequent heads always needs initialization and must not enable BIOS */
     novga = 1;
     nobios = 1;
     noinit = 0;
   } else {
     minfo->devflags.novga = 1;
     minfo->devflags.nobios = 1;
     minfo->devflags.noinit = 0;
   }
   minfo->devflags.nopciretry = no_pci_retry;
   minfo->devflags.mga_24bpp_fix = inv24;
   minfo->devflags.precise_width = option_precise_width;
   minfo->devflags.sgram = sgram;
   minfo->capable.cross4MB = cross4MB;
   spin_lock_init(&minfo->lock.DAC);
   spin_lock_init(&minfo->lock.accel);
   init_rwsem(&minfo->crtc2.lock);
   init_rwsem(&minfo->altout.lock);
   mutex_init(&minfo->fbcon.mm_lock);
   minfo->irq_flags = 0;
   init_waitqueue_head(&minfo->crtc1.vsync.wait);
   init_waitqueue_head(&minfo->crtc2.vsync.wait);
   minfo->crtc1.panpos = -1;
   err = initMatrox2(minfo, b);
   if (!err) {
     matroxfb_register_device(minfo);
     return 0;
   }
   kfree(minfo);
   return -1;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,52 +1,51 @@
 int ipv6_dev_mc_inc(struct net_device *dev, struct in6_addr *addr) {
   struct ifmcaddr6 *mc;
   struct inet6_dev *idev;
   idev = in6_dev_get(dev);
   if (idev == NULL) return -EINVAL;
   write_lock_bh(&idev->lock);
   if (idev->dead) {
     write_unlock_bh(&idev->lock);
     in6_dev_put(idev);
     return -ENODEV;
   }
   for (mc = idev->mc_list; mc; mc = mc->next) {
     if (ipv6_addr_equal(&mc->mca_addr, addr)) {
       mc->mca_users++;
       write_unlock_bh(&idev->lock);
       ip6_mc_add_src(idev, &mc->mca_addr, MCAST_EXCLUDE, 0, NULL, 0);
       in6_dev_put(idev);
       return 0;
     }
   }
   /*
    *	not found: create a new one.
    */
-  mc = kmalloc(sizeof(struct ifmcaddr6), GFP_ATOMIC);
+  mc = kzalloc(sizeof(struct ifmcaddr6), GFP_ATOMIC);
   if (mc == NULL) {
     write_unlock_bh(&idev->lock);
     in6_dev_put(idev);
     return -ENOMEM;
   }
-  memset(mc, 0, sizeof(struct ifmcaddr6));
   init_timer(&mc->mca_timer);
   mc->mca_timer.function = igmp6_timer_handler;
   mc->mca_timer.data = (unsigned long)mc;
   ipv6_addr_copy(&mc->mca_addr, addr);
   mc->idev = idev;
   mc->mca_users = 1;
   /* mca_stamp should be updated upon changes */
   mc->mca_cstamp = mc->mca_tstamp = jiffies;
   atomic_set(&mc->mca_refcnt, 2);
   spin_lock_init(&mc->mca_lock);
   /* initial mode is (EX, empty) */
   mc->mca_sfmode = MCAST_EXCLUDE;
   mc->mca_sfcount[MCAST_EXCLUDE] = 1;
   if (ipv6_addr_is_ll_all_nodes(&mc->mca_addr) || IPV6_ADDR_MC_SCOPE(&mc->mca_addr) < IPV6_ADDR_SCOPE_LINKLOCAL) mc->mca_flags |= MAF_NOREPORT;
   mc->next = idev->mc_list;
   idev->mc_list = mc;
   write_unlock_bh(&idev->lock);
   mld_del_delrec(idev, &mc->mca_addr);
   igmp6_group_added(mc);
   ma_put(mc);
   return 0;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,37 +1,36 @@
 struct cfcnfg *cfcnfg_create(void) {
   struct cfcnfg *this;
   struct cfctrl_rsp *resp;
   /* Initiate this layer */
-  this = kmalloc(sizeof(struct cfcnfg), GFP_ATOMIC);
+  this = kzalloc(sizeof(struct cfcnfg), GFP_ATOMIC);
   if (!this) {
     pr_warning("CAIF: %s(): Out of memory\n", __func__);
     return NULL;
   }
-  memset(this, 0, sizeof(struct cfcnfg));
   this->mux = cfmuxl_create();
   if (!this->mux) goto out_of_mem;
   this->ctrl = cfctrl_create();
   if (!this->ctrl) goto out_of_mem;
   /* Initiate response functions */
   resp = cfctrl_get_respfuncs(this->ctrl);
   resp->enum_rsp = cfctrl_enum_resp;
   resp->linkerror_ind = cfctrl_resp_func;
   resp->linkdestroy_rsp = cfcnfg_linkdestroy_rsp;
   resp->sleep_rsp = cfctrl_resp_func;
   resp->wake_rsp = cfctrl_resp_func;
   resp->restart_rsp = cfctrl_resp_func;
   resp->radioset_rsp = cfctrl_resp_func;
   resp->linksetup_rsp = cfcnfg_linkup_rsp;
   resp->reject_rsp = cfcnfg_reject_rsp;
   this->last_phyid = 1;
   cfmuxl_set_uplayer(this->mux, this->ctrl, 0);
   layer_set_dn(this->ctrl, this->mux);
   layer_set_up(this->ctrl, this);
   return this;
 out_of_mem:
   pr_warning("CAIF: %s(): Out of memory\n", __func__);
   kfree(this->mux);
   kfree(this->ctrl);
   kfree(this);
   return NULL;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,27 +1,26 @@
 static struct usb_tx *alloc_tx_struct(int len) {
   struct usb_tx *t = NULL;
   int ret = 0;
-  t = kmalloc(sizeof(struct usb_tx), GFP_ATOMIC);
+  t = kzalloc(sizeof(struct usb_tx), GFP_ATOMIC);
   if (!t) {
     ret = -ENOMEM;
     goto out;
   }
-  memset(t, 0, sizeof(struct usb_tx));
   t->urb = usb_alloc_urb(0, GFP_ATOMIC);
   if (!(len % 512)) len++;
   t->buf = kmalloc(len, GFP_ATOMIC);
   if (!t->urb || !t->buf) {
     ret = -ENOMEM;
     goto out;
   }
 out:
   if (ret < 0) {
     if (t) {
       usb_free_urb(t->urb);
       kfree(t->buf);
       kfree(t);
     }
     return NULL;
   }
   return t;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,54 +1,53 @@
 static struct ip6_flowlabel *fl_create(struct in6_flowlabel_req *freq, char __user *optval, int optlen, int *err_p) {
   struct ip6_flowlabel *fl;
   int olen;
   int addr_type;
   int err;
   err = -ENOMEM;
-  fl = kmalloc(sizeof(*fl), GFP_KERNEL);
+  fl = kzalloc(sizeof(*fl), GFP_KERNEL);
   if (fl == NULL) goto done;
-  memset(fl, 0, sizeof(*fl));
   olen = optlen - CMSG_ALIGN(sizeof(*freq));
   if (olen > 0) {
     struct msghdr msg;
     struct flowi flowi;
     int junk;
     err = -ENOMEM;
     fl->opt = kmalloc(sizeof(*fl->opt) + olen, GFP_KERNEL);
     if (fl->opt == NULL) goto done;
     memset(fl->opt, 0, sizeof(*fl->opt));
     fl->opt->tot_len = sizeof(*fl->opt) + olen;
     err = -EFAULT;
     if (copy_from_user(fl->opt + 1, optval + CMSG_ALIGN(sizeof(*freq)), olen)) goto done;
     msg.msg_controllen = olen;
     msg.msg_control = (void *)(fl->opt + 1);
     flowi.oif = 0;
     err = datagram_send_ctl(&msg, &flowi, fl->opt, &junk, &junk);
     if (err) goto done;
     err = -EINVAL;
     if (fl->opt->opt_flen) goto done;
     if (fl->opt->opt_nflen == 0) {
       kfree(fl->opt);
       fl->opt = NULL;
     }
   }
   fl->expires = jiffies;
   err = fl6_renew(fl, freq->flr_linger, freq->flr_expires);
   if (err) goto done;
   fl->share = freq->flr_share;
   addr_type = ipv6_addr_type(&freq->flr_dst);
   if ((addr_type & IPV6_ADDR_MAPPED) || addr_type == IPV6_ADDR_ANY) goto done;
   ipv6_addr_copy(&fl->dst, &freq->flr_dst);
   atomic_set(&fl->users, 1);
   switch (fl->share) {
   case IPV6_FL_S_EXCL:
   case IPV6_FL_S_ANY: break;
   case IPV6_FL_S_PROCESS: fl->owner = current->pid; break;
   case IPV6_FL_S_USER: fl->owner = current->euid; break;
   default: err = -EINVAL; goto done;
   }
   return fl;
 done:
   fl_free(fl);
   *err_p = err;
   return NULL;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,26 +1,25 @@
 struct dvb_frontend *cx24116_attach(const struct cx24116_config *config, struct i2c_adapter *i2c) {
   struct cx24116_state *state = NULL;
   int ret;
   dprintk("%s\n", __func__);
   /* allocate memory for the internal state */
-  state = kmalloc(sizeof(struct cx24116_state), GFP_KERNEL);
+  state = kzalloc(sizeof(struct cx24116_state), GFP_KERNEL);
   if (state == NULL) goto error1;
   /* setup the state */
-  memset(state, 0, sizeof(struct cx24116_state));
   state->config = config;
   state->i2c = i2c;
   /* check if the demod is present */
   ret = (cx24116_readreg(state, 0xFF) << 8) | cx24116_readreg(state, 0xFE);
   if (ret != 0x0501) {
     printk(KERN_INFO "Invalid probe, probably not a CX24116 device\n");
     goto error2;
   }
   /* create dvb_frontend */
   memcpy(&state->frontend.ops, &cx24116_ops, sizeof(struct dvb_frontend_ops));
   state->frontend.demodulator_priv = state;
   return &state->frontend;
 error2:
   kfree(state);
 error1:
   return NULL;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,47 +1,45 @@
 int wl_iw_attach(struct net_device *dev, void *dhdp) {
   int params_size;
   wl_iw_t *iw;
 #if defined(WL_IW_USE_ISCAN)
   iscan_info_t *iscan = NULL;
   if (!dev) return 0;
   memset(&g_wl_iw_params, 0, sizeof(wl_iw_extra_params_t));
 #ifdef CSCAN
   params_size = (WL_SCAN_PARAMS_FIXED_SIZE + offsetof(wl_iscan_params_t, params)) + (WL_NUMCHANNELS * sizeof(u16)) + WL_SCAN_PARAMS_SSID_MAX * sizeof(wlc_ssid_t);
 #else
   params_size = (WL_SCAN_PARAMS_FIXED_SIZE + offsetof(wl_iscan_params_t, params));
 #endif
-  iscan = kmalloc(sizeof(iscan_info_t), GFP_KERNEL);
+  iscan = kzalloc(sizeof(iscan_info_t), GFP_KERNEL);
   if (!iscan) return -ENOMEM;
-  memset(iscan, 0, sizeof(iscan_info_t));
   iscan->iscan_ex_params_p = kmalloc(params_size, GFP_KERNEL);
   if (!iscan->iscan_ex_params_p) return -ENOMEM;
   iscan->iscan_ex_param_size = params_size;
   iscan->sysioc_tsk = NULL;
   g_iscan = iscan;
   iscan->dev = dev;
   iscan->iscan_state = ISCAN_STATE_IDLE;
   iscan->timer_ms = 3000;
   init_timer(&iscan->timer);
   iscan->timer.data = (unsigned long)iscan;
   iscan->timer.function = wl_iw_timerfunc;
   sema_init(&iscan->sysioc_sem, 0);
   iscan->sysioc_tsk = kthread_run(_iscan_sysioc_thread, iscan, "_iscan_sysioc");
   if (IS_ERR(iscan->sysioc_tsk)) {
     iscan->sysioc_tsk = NULL;
     return -ENOMEM;
   }
 #endif /* defined(WL_IW_USE_ISCAN) */
   iw = *(wl_iw_t **)netdev_priv(dev);
   iw->pub = (dhd_pub_t *)dhdp;
   MUTEX_LOCK_INIT(iw->pub);
   MUTEX_LOCK_WL_SCAN_SET_INIT();
 #ifdef SOFTAP
   priv_dev = dev;
   MUTEX_LOCK_SOFTAP_SET_INIT(iw->pub);
 #endif
-  g_scan = kmalloc(G_SCAN_RESULTS, GFP_KERNEL);
+  g_scan = kzalloc(G_SCAN_RESULTS, GFP_KERNEL);
   if (!g_scan) return -ENOMEM;
-  memset(g_scan, 0, G_SCAN_RESULTS);
   g_scan_specified_ssid = 0;
   return 0;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,18 +1,17 @@
 static struct usb_tx *alloc_tx_struct(struct tx_cxt *tx) {
   struct usb_tx *t = NULL;
-  t = kmalloc(sizeof(*t), GFP_ATOMIC);
+  t = kzalloc(sizeof(*t), GFP_ATOMIC);
   if (t == NULL) goto out;
-  memset(t, 0, sizeof(*t));
   t->urb = usb_alloc_urb(0, GFP_ATOMIC);
   t->buf = kmalloc(TX_BUF_SIZE, GFP_ATOMIC);
   if (t->urb == NULL || t->buf == NULL) goto out;
   t->tx_cxt = tx;
   return t;
 out:
   if (t) {
     usb_free_urb(t->urb);
     kfree(t->buf);
     kfree(t);
   }
   return NULL;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,17 +1,16 @@
 static int bcsp_open(struct hci_uart *hu) {
   struct bcsp_struct *bcsp;
   BT_DBG("hu %p", hu);
-  bcsp = kmalloc(sizeof(*bcsp), GFP_ATOMIC);
+  bcsp = kzalloc(sizeof(*bcsp), GFP_ATOMIC);
   if (!bcsp) return -ENOMEM;
-  memset(bcsp, 0, sizeof(*bcsp));
   hu->priv = bcsp;
   skb_queue_head_init(&bcsp->unack);
   skb_queue_head_init(&bcsp->rel);
   skb_queue_head_init(&bcsp->unrel);
   init_timer(&bcsp->tbcsp);
   bcsp->tbcsp.function = bcsp_timed_event;
   bcsp->tbcsp.data = (u_long)hu;
   bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
   if (txcrc) bcsp->use_crc = 1;
   return 0;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,15 +1,14 @@
 static int drm_add_magic(struct drm_master *master, struct drm_file *priv, drm_magic_t magic) {
   struct drm_magic_entry *entry;
   struct drm_device *dev = master->minor->dev;
   DRM_DEBUG("%d\n", magic);
-  entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+  entry = kzalloc(sizeof(*entry), GFP_KERNEL);
   if (!entry) return -ENOMEM;
-  memset(entry, 0, sizeof(*entry));
   entry->priv = priv;
   entry->hash_item.key = (unsigned long)magic;
   mutex_lock(&dev->struct_mutex);
   drm_ht_insert_item(&master->magiclist, &entry->hash_item);
   list_add_tail(&entry->head, &master->magicfree);
   mutex_unlock(&dev->struct_mutex);
   return 0;
 }<sep>@@
expression e1,e2,e3;
identifier print1,print2;
constant char[] c1;
constant char[] c2;
statement S;
@@

-       e3 = kmalloc(e1, e2)
+       e3 = kzalloc(e1, e2)
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
       ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);
--- initial
+++ final
@@ -1,16 +1,15 @@
 static int ip6fl_seq_open(struct inode *inode, struct file *file) {
   struct seq_file *seq;
   int rc = -ENOMEM;
-  struct ip6fl_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL);
+  struct ip6fl_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
   if (!s) goto out;
   rc = seq_open(file, &ip6fl_seq_ops);
   if (rc) goto out_kfree;
   seq = file->private_data;
   seq->private = s;
-  memset(s, 0, sizeof(*s));
 out:
   return rc;
 out_kfree:
   kfree(s);
   goto out;
 }<sep>@@
expression e1,e2,r;
statement S;
identifier e3,print1,print2,print3;
constant char[] c1;
constant char[] c2;
constant char[] c3;
type T;
@@

	T e3 =
-       kmalloc
+       kzalloc
	   (e1, e2);
        <... when != e3
(
	print1(...,c1,...,e3,...);
|
	kfree(e3);
)
        ...>
        if (e3 == NULL || ...) S
        <... when != e3
(
	print2(...,c2,...,e3,...);
|
	kfree(e3);
)
        ...>
(
	r = e3;
|
	dev_set_drvdata(r,e3);
)
	<... when != e3
	     when != r
(
	print3(...,c3,...,e3,...);
|
	kfree(e3);
)
        ...>
-       memset(e3, 0, e1);