From: dhill Date: Sun, 9 Apr 2017 18:09:41 +0000 (+0000) Subject: Convert some malloc(9) to mallocarray(9) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=92751d6e8a63834684348a0b504f963c4a24fe73;p=openbsd Convert some malloc(9) to mallocarray(9) ok deraadt@ --- diff --git a/sys/dev/usb/dwc2/dwc2_hcd.c b/sys/dev/usb/dwc2/dwc2_hcd.c index 8e7ebf63d37..dee59662862 100644 --- a/sys/dev/usb/dwc2/dwc2_hcd.c +++ b/sys/dev/usb/dwc2/dwc2_hcd.c @@ -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; diff --git a/sys/dev/usb/dwc2/dwc2_hcdddma.c b/sys/dev/usb/dwc2/dwc2_hcdddma.c index d20647f8c7b..3628a8bcd11 100644 --- a/sys/dev/usb/dwc2/dwc2_hcdddma.c +++ b/sys/dev/usb/dwc2/dwc2_hcdddma.c @@ -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;