imamnurby/smpl_train_seed8 huggingface dataset:
--- initial
+++ final
@@ -1,33 +1,33 @@
 static void dwc2_wakeup_from_lpm_l1(struct dwc2_hsotg *hsotg) {
   u32 glpmcfg;
   u32 i = 0;
   if (hsotg->lx_state != DWC2_L1) {
     dev_err(hsotg->dev, "Core isn't in DWC2_L1 state\n");
     return;
   }
-  glpmcfg = dwc2_readl(hsotg->regs + GLPMCFG);
+  glpmcfg = dwc2_readl(hsotg, GLPMCFG);
   if (dwc2_is_device_mode(hsotg)) {
     dev_dbg(hsotg->dev, "Exit from L1 state\n");
     glpmcfg &= ~GLPMCFG_ENBLSLPM;
     glpmcfg &= ~GLPMCFG_HIRD_THRES_EN;
-    dwc2_writel(glpmcfg, hsotg->regs + GLPMCFG);
+    dwc2_writel(hsotg, glpmcfg, GLPMCFG);
     do {
-      glpmcfg = dwc2_readl(hsotg->regs + GLPMCFG);
+      glpmcfg = dwc2_readl(hsotg, GLPMCFG);
       if (!(glpmcfg & (GLPMCFG_COREL1RES_MASK | GLPMCFG_L1RESUMEOK | GLPMCFG_SLPSTS))) break;
       udelay(1);
     } while (++i < 200);
     if (i == 200) {
       dev_err(hsotg->dev, "Failed to exit L1 sleep state in 200us.\n");
       return;
     }
     dwc2_gadget_init_lpm(hsotg);
   } else {
     /* TODO */
     dev_err(hsotg->dev, "Host side LPM is not supported.\n");
     return;
   }
   /* Change to L0 state */
   hsotg->lx_state = DWC2_L0;
   /* Inform gadget to exit from L1 */
   call_gadget(hsotg, resume);
 }<sep>@@
expression hsotg,e;
@@

- dwc2_readl(hsotg->regs + e)
+ dwc2_readl(hsotg, e)

@@
expression hsotg,e,v;
@@
- dwc2_writel(v, hsotg->regs + e)
+ dwc2_writel(hsotg, v, e)
--- initial
+++ final
@@ -1,53 +1,53 @@
 static int _dwc2_hcd_resume(struct usb_hcd *hcd) {
   struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
   unsigned long flags;
   int ret = 0;
   spin_lock_irqsave(&hsotg->lock, flags);
   if (dwc2_is_device_mode(hsotg)) goto unlock;
   if (hsotg->lx_state != DWC2_L2) goto unlock;
   if (hsotg->params.power_down != DWC2_POWER_DOWN_PARAM_PARTIAL) {
     hsotg->lx_state = DWC2_L0;
     goto unlock;
   }
   /*
    * Set HW accessible bit before powering on the controller
    * since an interrupt may rise.
    */
   set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
   /*
    * Enable power if not already done.
    * This must not be spinlocked since duration
    * of this call is unknown.
    */
   if (!IS_ERR_OR_NULL(hsotg->uphy)) {
     spin_unlock_irqrestore(&hsotg->lock, flags);
     usb_phy_set_suspend(hsotg->uphy, false);
     spin_lock_irqsave(&hsotg->lock, flags);
   }
   /* Exit partial_power_down */
   ret = dwc2_exit_partial_power_down(hsotg, true);
   if (ret && (ret != -ENOTSUPP)) dev_err(hsotg->dev, "exit partial_power_down failed\n");
   hsotg->lx_state = DWC2_L0;
   spin_unlock_irqrestore(&hsotg->lock, flags);
   if (hsotg->bus_suspended) {
     spin_lock_irqsave(&hsotg->lock, flags);
     hsotg->flags.b.port_suspend_change = 1;
     spin_unlock_irqrestore(&hsotg->lock, flags);
     dwc2_port_resume(hsotg);
   } else {
     dwc2_vbus_supply_init(hsotg);
     /* Wait for controller to correctly update D+/D- level */
     usleep_range(3000, 5000);
     /*
      * Clear Port Enable and Port Status changes.
      * Enable Port Power.
      */
-    dwc2_writel(HPRT0_PWR | HPRT0_CONNDET | HPRT0_ENACHG, hsotg->regs + HPRT0);
+    dwc2_writel(hsotg, HPRT0_PWR | HPRT0_CONNDET | HPRT0_ENACHG, HPRT0);
     /* Wait for controller to detect Port Connect */
     usleep_range(5000, 7000);
   }
   return ret;
 unlock:
   spin_unlock_irqrestore(&hsotg->lock, flags);
   return ret;
 }<sep>@@
expression hsotg,e,v;
@@
- dwc2_writel(v, hsotg->regs + e)
+ dwc2_writel(hsotg, v, e)
--- initial
+++ final
@@ -1,4 +1,4 @@
 static void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) {
   /* set the soft-disconnect bit */
-  dwc2_set_bit(hsotg->regs + DCTL, DCTL_SFTDISCON);
+  dwc2_set_bit(hsotg, DCTL, DCTL_SFTDISCON);
 }<sep>@@
expression e1,e2,hsotg;
@@
-	dwc2_set_bit(hsotg->regs + e1, e2)
+	dwc2_set_bit(hsotg, e1, e2)
--- initial
+++ final
@@ -1,39 +1,39 @@
 static void dwc2_port_suspend(struct dwc2_hsotg *hsotg, u16 windex) {
   unsigned long flags;
   u32 hprt0;
   u32 pcgctl;
   u32 gotgctl;
   dev_dbg(hsotg->dev, "%s()\n", __func__);
   spin_lock_irqsave(&hsotg->lock, flags);
   if (windex == hsotg->otg_port && dwc2_host_is_b_hnp_enabled(hsotg)) {
-    gotgctl = dwc2_readl(hsotg->regs + GOTGCTL);
+    gotgctl = dwc2_readl(hsotg, GOTGCTL);
     gotgctl |= GOTGCTL_HSTSETHNPEN;
-    dwc2_writel(gotgctl, hsotg->regs + GOTGCTL);
+    dwc2_writel(hsotg, gotgctl, GOTGCTL);
     hsotg->op_state = OTG_STATE_A_SUSPEND;
   }
   hprt0 = dwc2_read_hprt0(hsotg);
   hprt0 |= HPRT0_SUSP;
-  dwc2_writel(hprt0, hsotg->regs + HPRT0);
+  dwc2_writel(hsotg, hprt0, HPRT0);
   hsotg->bus_suspended = true;
   /*
    * If power_down is supported, Phy clock will be suspended
    * after registers are backuped.
    */
   if (!hsotg->params.power_down) {
     /* Suspend the Phy Clock */
-    pcgctl = dwc2_readl(hsotg->regs + PCGCTL);
+    pcgctl = dwc2_readl(hsotg, PCGCTL);
     pcgctl |= PCGCTL_STOPPCLK;
-    dwc2_writel(pcgctl, hsotg->regs + PCGCTL);
+    dwc2_writel(hsotg, pcgctl, PCGCTL);
     udelay(10);
   }
   /* For HNP the bus must be suspended for at least 200ms */
   if (dwc2_host_is_b_hnp_enabled(hsotg)) {
-    pcgctl = dwc2_readl(hsotg->regs + PCGCTL);
+    pcgctl = dwc2_readl(hsotg, PCGCTL);
     pcgctl &= ~PCGCTL_STOPPCLK;
-    dwc2_writel(pcgctl, hsotg->regs + PCGCTL);
+    dwc2_writel(hsotg, pcgctl, PCGCTL);
     spin_unlock_irqrestore(&hsotg->lock, flags);
     msleep(200);
   } else {
     spin_unlock_irqrestore(&hsotg->lock, flags);
   }
 }<sep>@@
expression hsotg,e;
@@

- dwc2_readl(hsotg->regs + e)
+ dwc2_readl(hsotg, e)

@@
expression hsotg,e,v;
@@
- dwc2_writel(v, hsotg->regs + e)
+ dwc2_writel(hsotg, v, e)
--- initial
+++ final
@@ -1,65 +1,65 @@
 static void dwc2_release_channel(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan, struct dwc2_qtd *qtd, enum dwc2_halt_status halt_status) {
   enum dwc2_transaction_type tr_type;
   u32 haintmsk;
   int free_qtd = 0;
   if (dbg_hc(chan)) dev_vdbg(hsotg->dev, "  %s: channel %d, halt_status %d\n", __func__, chan->hc_num, halt_status);
   switch (halt_status) {
   case DWC2_HC_XFER_URB_COMPLETE: free_qtd = 1; break;
   case DWC2_HC_XFER_AHB_ERR:
   case DWC2_HC_XFER_STALL:
   case DWC2_HC_XFER_BABBLE_ERR: free_qtd = 1; break;
   case DWC2_HC_XFER_XACT_ERR:
     if (qtd && qtd->error_count >= 3) {
       dev_vdbg(hsotg->dev, "  Complete URB with transaction error\n");
       free_qtd = 1;
       dwc2_host_complete(hsotg, qtd, -EPROTO);
     }
     break;
   case DWC2_HC_XFER_URB_DEQUEUE:
     /*
      * The QTD has already been removed and the QH has been
      * deactivated. Don't want to do anything except release the
      * host channel and try to queue more transfers.
      */
     goto cleanup;
   case DWC2_HC_XFER_PERIODIC_INCOMPLETE:
     dev_vdbg(hsotg->dev, "  Complete URB with I/O error\n");
     free_qtd = 1;
     dwc2_host_complete(hsotg, qtd, -EIO);
     break;
   case DWC2_HC_XFER_NO_HALT_STATUS:
   default: break;
   }
   dwc2_deactivate_qh(hsotg, chan->qh, free_qtd);
 cleanup:
   /*
    * Release the host channel for use by other transfers. The cleanup
    * function clears the channel interrupt enables and conditions, so
    * there's no need to clear the Channel Halted interrupt separately.
    */
   if (!list_empty(&chan->hc_list_entry)) list_del(&chan->hc_list_entry);
   dwc2_hc_cleanup(hsotg, chan);
   list_add_tail(&chan->hc_list_entry, &hsotg->free_hc_list);
   if (hsotg->params.uframe_sched) {
     hsotg->available_host_channels++;
   } else {
     switch (chan->ep_type) {
     case USB_ENDPOINT_XFER_CONTROL:
     case USB_ENDPOINT_XFER_BULK: hsotg->non_periodic_channels--; break;
     default:
       /*
        * Don't release reservations for periodic channels
        * here. That's done when a periodic transfer is
        * descheduled (i.e. when the QH is removed from the
        * periodic schedule).
        */
       break;
     }
   }
-  haintmsk = dwc2_readl(hsotg->regs + HAINTMSK);
+  haintmsk = dwc2_readl(hsotg, HAINTMSK);
   haintmsk &= ~(1 << chan->hc_num);
-  dwc2_writel(haintmsk, hsotg->regs + HAINTMSK);
+  dwc2_writel(hsotg, haintmsk, HAINTMSK);
   /* Try to queue more transfers now that there's a free channel */
   tr_type = dwc2_hcd_select_transactions(hsotg);
   if (tr_type != DWC2_TRANSACTION_NONE) dwc2_hcd_queue_transactions(hsotg, tr_type);
 }<sep>@@
expression hsotg,e;
@@

- dwc2_readl(hsotg->regs + e)
+ dwc2_readl(hsotg, e)

@@
expression hsotg,e,v;
@@
- dwc2_writel(v, hsotg->regs + e)
+ dwc2_writel(hsotg, v, e)
--- initial
+++ final
@@ -1,13 +1,13 @@
 void dwc2_hc_cleanup(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan) {
   u32 hcintmsk;
   chan->xfer_started = 0;
   list_del_init(&chan->split_order_list_entry);
   /*
    * Clear channel interrupt enables and any unhandled channel interrupt
    * conditions
    */
-  dwc2_writel(0, hsotg->regs + HCINTMSK(chan->hc_num));
+  dwc2_writel(hsotg, 0, HCINTMSK(chan->hc_num));
   hcintmsk = 0xffffffff;
   hcintmsk &= ~HCINTMSK_RESERVED14_31;
-  dwc2_writel(hcintmsk, hsotg->regs + HCINT(chan->hc_num));
+  dwc2_writel(hsotg, hcintmsk, HCINT(chan->hc_num));
 }<sep>@@
expression hsotg,e,v;
@@
- dwc2_writel(v, hsotg->regs + e)
+ dwc2_writel(hsotg, v, e)
--- initial
+++ final
@@ -1,25 +1,24 @@
 static int tg3_alloc_consistent(struct tg3 *tp) {
-  tp->rx_std_buffers = kmalloc((sizeof(struct ring_info) * (TG3_RX_RING_SIZE + TG3_RX_JUMBO_RING_SIZE)) + (sizeof(struct tx_ring_info) * TG3_TX_RING_SIZE), GFP_KERNEL);
+  tp->rx_std_buffers = kzalloc((sizeof(struct ring_info) * (TG3_RX_RING_SIZE + TG3_RX_JUMBO_RING_SIZE)) + (sizeof(struct tx_ring_info) * TG3_TX_RING_SIZE), GFP_KERNEL);
   if (!tp->rx_std_buffers) return -ENOMEM;
-  memset(tp->rx_std_buffers, 0, (sizeof(struct ring_info) * (TG3_RX_RING_SIZE + TG3_RX_JUMBO_RING_SIZE)) + (sizeof(struct tx_ring_info) * TG3_TX_RING_SIZE));
   tp->rx_jumbo_buffers = &tp->rx_std_buffers[TG3_RX_RING_SIZE];
   tp->tx_buffers = (struct tx_ring_info *)&tp->rx_jumbo_buffers[TG3_RX_JUMBO_RING_SIZE];
   tp->rx_std = pci_alloc_consistent(tp->pdev, TG3_RX_RING_BYTES, &tp->rx_std_mapping);
   if (!tp->rx_std) goto err_out;
   tp->rx_jumbo = pci_alloc_consistent(tp->pdev, TG3_RX_JUMBO_RING_BYTES, &tp->rx_jumbo_mapping);
   if (!tp->rx_jumbo) goto err_out;
   tp->rx_rcb = pci_alloc_consistent(tp->pdev, TG3_RX_RCB_RING_BYTES(tp), &tp->rx_rcb_mapping);
   if (!tp->rx_rcb) goto err_out;
   tp->tx_ring = pci_alloc_consistent(tp->pdev, TG3_TX_RING_BYTES, &tp->tx_desc_mapping);
   if (!tp->tx_ring) goto err_out;
   tp->hw_status = pci_alloc_consistent(tp->pdev, TG3_HW_STATUS_SIZE, &tp->status_mapping);
   if (!tp->hw_status) goto err_out;
   tp->hw_stats = pci_alloc_consistent(tp->pdev, sizeof(struct tg3_hw_stats), &tp->stats_mapping);
   if (!tp->hw_stats) goto err_out;
   memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE);
   memset(tp->hw_stats, 0, sizeof(struct tg3_hw_stats));
   return 0;
 err_out:
   tg3_free_consistent(tp);
   return -ENOMEM;
 }<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,50 +1,49 @@
 static int wl_iw_get_aplist(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) {
   wl_scan_results_t *list;
   struct sockaddr *addr = (struct sockaddr *)extra;
   struct iw_quality qual[IW_MAX_AP];
   wl_bss_info_t *bi = NULL;
   int error, i;
   uint buflen = dwrq->length;
   WL_TRACE("%s: SIOCGIWAPLIST\n", dev->name);
   if (!extra) return -EINVAL;
-  list = kmalloc(buflen, GFP_KERNEL);
+  list = kzalloc(buflen, GFP_KERNEL);
   if (!list) return -ENOMEM;
-  memset(list, 0, buflen);
   list->buflen = cpu_to_le32(buflen);
   error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, buflen);
   if (error) {
     WL_ERROR("%d: Scan results error %d\n", __LINE__, error);
     kfree(list);
     return error;
   }
   list->buflen = le32_to_cpu(list->buflen);
   list->version = le32_to_cpu(list->version);
   list->count = le32_to_cpu(list->count);
   if (list->version != WL_BSS_INFO_VERSION) {
     WL_ERROR("%s : list->version %d != WL_BSS_INFO_VERSION\n", __func__, list->version);
     kfree(list);
     return -EINVAL;
   }
   for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) {
     bi = bi ? (wl_bss_info_t *)((unsigned long)bi + le32_to_cpu(bi->length)) : list->bss_info;
     ASSERT(((unsigned long)bi + le32_to_cpu(bi->length)) <= ((unsigned long)list + buflen));
     if (!(le16_to_cpu(bi->capability) & WLAN_CAPABILITY_ESS)) continue;
     memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETH_ALEN);
     addr[dwrq->length].sa_family = ARPHRD_ETHER;
     qual[dwrq->length].qual = rssi_to_qual(le16_to_cpu(bi->RSSI));
     qual[dwrq->length].level = 0x100 + le16_to_cpu(bi->RSSI);
     qual[dwrq->length].noise = 0x100 + bi->phy_noise;
 #if WIRELESS_EXT > 18
     qual[dwrq->length].updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
 #else
     qual[dwrq->length].updated = 7;
 #endif
     dwrq->length++;
   }
   kfree(list);
   if (dwrq->length) {
     memcpy(&addr[dwrq->length], qual, sizeof(struct iw_quality) * dwrq->length);
     dwrq->flags = 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,16 +1,15 @@
 static int ac6_seq_open(struct inode *inode, struct file *file) {
   struct seq_file *seq;
   int rc = -ENOMEM;
-  struct ac6_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL);
+  struct ac6_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
   if (!s) goto out;
   rc = seq_open(file, &ac6_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);
--- initial
+++ final
@@ -1,87 +1,86 @@
 int save_vga(struct vgastate *state) {
   struct regstate *saved;
-  saved = kmalloc(sizeof(struct regstate), GFP_KERNEL);
+  saved = kzalloc(sizeof(struct regstate), GFP_KERNEL);
   if (saved == NULL) return 1;
-  memset(saved, 0, sizeof(struct regstate));
   state->vidstate = (void *)saved;
 
   if (state->flags & VGA_SAVE_CMAP) {
     saved->vga_cmap = vmalloc(768);
     if (!saved->vga_cmap) {
       vga_cleanup(state);
       return 1;
     }
     save_vga_cmap(state);
   }
   if (state->flags & VGA_SAVE_MODE) {
     int total;
     if (state->num_attr < 21) state->num_attr = 21;
     if (state->num_crtc < 25) state->num_crtc = 25;
     if (state->num_gfx < 9) state->num_gfx = 9;
     if (state->num_seq < 5) state->num_seq = 5;
     total = state->num_attr + state->num_crtc + state->num_gfx + state->num_seq;
     saved->attr = vmalloc(total);
     if (!saved->attr) {
       vga_cleanup(state);
       return 1;
     }
     saved->crtc = saved->attr + state->num_attr;
     saved->gfx = saved->crtc + state->num_crtc;
     saved->seq = saved->gfx + state->num_gfx;
     save_vga_mode(state);
   }
   if (state->flags & VGA_SAVE_FONTS) {
     void __iomem *fbbase;
     /* exit if window is less than 32K */
     if (state->memsize && state->memsize < 4 * 8192) {
       vga_cleanup(state);
       return 1;
     }
     if (!state->memsize) state->memsize = 8 * 8192;
 
     if (!state->membase) state->membase = 0xA0000;
     fbbase = ioremap(state->membase, state->memsize);
     if (!fbbase) {
       vga_cleanup(state);
       return 1;
     }
     /*
      * save only first 32K used by vgacon
      */
     if (state->flags & VGA_SAVE_FONT0) {
       saved->vga_font0 = vmalloc(4 * 8192);
       if (!saved->vga_font0) {
         iounmap(fbbase);
         vga_cleanup(state);
         return 1;
       }
     }
     /*
      * largely unused, but if required by the caller
      * we'll just save everything.
      */
     if (state->flags & VGA_SAVE_FONT1) {
       saved->vga_font1 = vmalloc(state->memsize);
       if (!saved->vga_font1) {
         iounmap(fbbase);
         vga_cleanup(state);
         return 1;
       }
     }
     /*
      * Save 8K at plane0[0], and 8K at plane1[16K]
      */
     if (state->flags & VGA_SAVE_TEXT) {
       saved->vga_text = vmalloc(8192 * 2);
       if (!saved->vga_text) {
         iounmap(fbbase);
         vga_cleanup(state);
         return 1;
       }
     }
 
     save_vga_text(state, fbbase);
     iounmap(fbbase);
   }
   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,24 +1,23 @@
 static int garmin_attach(struct usb_serial *serial) {
   int status = 0;
   struct usb_serial_port *port = serial->port[0];
   struct garmin_data *garmin_data_p = NULL;
   dbg("%s", __FUNCTION__);
-  garmin_data_p = kmalloc(sizeof(struct garmin_data), GFP_KERNEL);
+  garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
   if (garmin_data_p == NULL) {
     dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__);
     return -ENOMEM;
   }
-  memset(garmin_data_p, 0, sizeof(struct garmin_data));
   init_timer(&garmin_data_p->timer);
   spin_lock_init(&garmin_data_p->lock);
   INIT_LIST_HEAD(&garmin_data_p->pktlist);
   // garmin_data_p->timer.expires = jiffies + session_timeout;
   garmin_data_p->timer.data = (unsigned long)garmin_data_p;
   garmin_data_p->timer.function = timeout_handler;
   garmin_data_p->port = port;
   garmin_data_p->state = 0;
   garmin_data_p->count = 0;
   usb_set_serial_port_data(port, garmin_data_p);
   status = garmin_init_session(port);
   return status;
 }<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 struct sdio_tx *alloc_tx_struct(struct tx_cxt *tx) {
   struct sdio_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->buf = kmalloc(TX_BUF_SIZE, GFP_ATOMIC);
   if (t->buf == NULL) goto out;
   t->tx_cxt = tx;
   return t;
 out:
   if (t) {
     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,58 +1,57 @@
 static int esp6_init_state(struct xfrm_state *x) {
   struct esp_data *esp = NULL;
   /* null auth and encryption can have zero length keys */
   if (x->aalg) {
     if (x->aalg->alg_key_len > 512) goto error;
   }
   if (x->ealg == NULL) goto error;
   if (x->encap) goto error;
-  esp = kmalloc(sizeof(*esp), GFP_KERNEL);
+  esp = kzalloc(sizeof(*esp), GFP_KERNEL);
   if (esp == NULL) return -ENOMEM;
-  memset(esp, 0, sizeof(*esp));
   if (x->aalg) {
     struct xfrm_algo_desc *aalg_desc;
     esp->auth.key = x->aalg->alg_key;
     esp->auth.key_len = (x->aalg->alg_key_len + 7) / 8;
     esp->auth.tfm = crypto_alloc_tfm(x->aalg->alg_name, 0);
     if (esp->auth.tfm == NULL) goto error;
     esp->auth.icv = esp_hmac_digest;
 
     aalg_desc = xfrm_aalg_get_byname(x->aalg->alg_name, 0);
     BUG_ON(!aalg_desc);
 
     if (aalg_desc->uinfo.auth.icv_fullbits / 8 != crypto_tfm_alg_digestsize(esp->auth.tfm)) {
       printk(KERN_INFO "ESP: %s digestsize %u != %hu\n", x->aalg->alg_name, crypto_tfm_alg_digestsize(esp->auth.tfm), aalg_desc->uinfo.auth.icv_fullbits / 8);
       goto error;
     }
 
     esp->auth.icv_full_len = aalg_desc->uinfo.auth.icv_fullbits / 8;
     esp->auth.icv_trunc_len = aalg_desc->uinfo.auth.icv_truncbits / 8;
 
     esp->auth.work_icv = kmalloc(esp->auth.icv_full_len, GFP_KERNEL);
     if (!esp->auth.work_icv) goto error;
   }
   esp->conf.key = x->ealg->alg_key;
   esp->conf.key_len = (x->ealg->alg_key_len + 7) / 8;
   if (x->props.ealgo == SADB_EALG_NULL)
     esp->conf.tfm = crypto_alloc_tfm(x->ealg->alg_name, CRYPTO_TFM_MODE_ECB);
   else
     esp->conf.tfm = crypto_alloc_tfm(x->ealg->alg_name, CRYPTO_TFM_MODE_CBC);
   if (esp->conf.tfm == NULL) goto error;
   esp->conf.ivlen = crypto_tfm_alg_ivsize(esp->conf.tfm);
   esp->conf.padlen = 0;
   if (esp->conf.ivlen) {
     esp->conf.ivec = kmalloc(esp->conf.ivlen, GFP_KERNEL);
     if (unlikely(esp->conf.ivec == NULL)) goto error;
     get_random_bytes(esp->conf.ivec, esp->conf.ivlen);
   }
   if (crypto_cipher_setkey(esp->conf.tfm, esp->conf.key, esp->conf.key_len)) goto error;
   x->props.header_len = sizeof(struct ipv6_esp_hdr) + esp->conf.ivlen;
   if (x->props.mode) x->props.header_len += sizeof(struct ipv6hdr);
   x->data = esp;
   return 0;
 error:
   x->data = esp;
   esp6_destroy(x);
   x->data = NULL;
   return -EINVAL;
 }<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 scan_for_bad_eraseblocks(void) {
   int i, bad = 0;
-  bbt = kmalloc(ebcnt, GFP_KERNEL);
+  bbt = kzalloc(ebcnt, GFP_KERNEL);
   if (!bbt) {
     printk(PRINT_PREF "error: cannot allocate memory\n");
     return -ENOMEM;
   }
-  memset(bbt, 0, ebcnt);
   printk(PRINT_PREF "scanning for bad eraseblocks\n");
   for (i = 0; i < ebcnt; ++i) {
     bbt[i] = is_block_bad(i) ? 1 : 0;
     if (bbt[i]) bad += 1;
     cond_resched();
   }
   printk(PRINT_PREF "scanned %d eraseblocks, %d are bad\n", i, bad);
   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);