Convert some malloc(9) to mallocarray(9)
authordhill <dhill@openbsd.org>
Sun, 9 Apr 2017 18:09:41 +0000 (18:09 +0000)
committerdhill <dhill@openbsd.org>
Sun, 9 Apr 2017 18:09:41 +0000 (18:09 +0000)
ok deraadt@

sys/dev/usb/dwc2/dwc2_hcd.c
sys/dev/usb/dwc2/dwc2_hcdddma.c

index 8e7ebf6..dee5966 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dwc2_hcd.c,v 1.16 2015/06/28 11:48:18 jmatthew Exp $  */
+/*     $OpenBSD: dwc2_hcd.c,v 1.17 2017/04/09 18:09:41 dhill Exp $     */
 /*     $NetBSD: dwc2_hcd.c,v 1.15 2014/11/24 10:14:14 skrll Exp $      */
 
 /*
@@ -2184,14 +2184,14 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg,
        dev_dbg(hsotg->dev, "hcfg=%08x\n", DWC2_READ_4(hsotg, HCFG));
 
 #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
-       hsotg->frame_num_array = malloc(sizeof(*hsotg->frame_num_array) *
-                                       FRAME_NUM_ARRAY_SIZE, M_DEVBUF,
-                                       M_ZERO | M_WAITOK);
+       hsotg->frame_num_array = mallocarray(FRAME_NUM_ARRAY_SIZE,
+                                       sizeof(*hsotg->frame_num_array), 
+                                       M_DEVBUF, M_ZERO | M_WAITOK);
        if (!hsotg->frame_num_array)
                goto error1;
-       hsotg->last_frame_num_array = malloc(
-                       sizeof(*hsotg->last_frame_num_array) *
-                       FRAME_NUM_ARRAY_SIZE, M_DEVBUF, M_ZERO | M_WAITOK);
+       hsotg->last_frame_num_array = mallocarray(FRAME_NUM_ARRAY_SIZE,
+                       sizeof(*hsotg->last_frame_num_array)
+                       M_DEVBUF, M_ZERO | M_WAITOK);
        if (!hsotg->last_frame_num_array)
                goto error1;
        hsotg->last_frame_num = HFNUM_MAX_FRNUM;
index d20647f..3628a8b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dwc2_hcdddma.c,v 1.11 2015/12/18 17:23:14 mmcc Exp $  */
+/*     $OpenBSD: dwc2_hcdddma.c,v 1.12 2017/04/09 18:09:41 dhill Exp $ */
 /*     $NetBSD: dwc2_hcdddma.c,v 1.6 2014/04/03 06:34:58 skrll Exp $   */
 
 /*
@@ -122,7 +122,7 @@ STATIC int dwc2_desc_list_alloc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,
        memset(qh->desc_list, 0,
               sizeof(struct dwc2_hcd_dma_desc) * dwc2_max_desc_num(qh));
 
-       qh->n_bytes = malloc(sizeof(u32) * dwc2_max_desc_num(qh), M_DEVBUF,
+       qh->n_bytes = mallocarray(dwc2_max_desc_num(qh), sizeof(u32), M_DEVBUF,
            M_ZERO | M_WAITOK);
 
        return 0;