From owner-svn-src-head@freebsd.org Thu Jan 11 15:25:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 148CEE6974B; Thu, 11 Jan 2018 15:25:28 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E01E57618B; Thu, 11 Jan 2018 15:25:27 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0523516BC4; Thu, 11 Jan 2018 15:25:27 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0BFPQYd084194; Thu, 11 Jan 2018 15:25:26 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0BFPQDn084190; Thu, 11 Jan 2018 15:25:26 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201801111525.w0BFPQDn084190@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Thu, 11 Jan 2018 15:25:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327828 - in head/sys/dev: e1000 ixl X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: in head/sys/dev: e1000 ixl X-SVN-Commit-Revision: 327828 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jan 2018 15:25:28 -0000 Author: pfg Date: Thu Jan 11 15:25:26 2018 New Revision: 327828 URL: https://svnweb.freebsd.org/changeset/base/327828 Log: dev/(e1000,ixl): Make some use of mallocarray(9). Reviewed by: erj Differential Revision: https://reviews.freebsd.org/D13833 Modified: head/sys/dev/e1000/if_em.c head/sys/dev/ixl/if_ixlv.c head/sys/dev/ixl/ixl_pf_iov.c head/sys/dev/ixl/ixl_pf_main.c Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Thu Jan 11 15:03:01 2018 (r327827) +++ head/sys/dev/e1000/if_em.c Thu Jan 11 15:25:26 2018 (r327828) @@ -2835,9 +2835,9 @@ em_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, u /* First allocate the top level queue structs */ if (!(adapter->tx_queues = - (struct em_tx_queue *) malloc(sizeof(struct em_tx_queue) * - adapter->tx_num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) { - device_printf(iflib_get_dev(ctx), "Unable to allocate queue memory\n"); + (struct em_tx_queue *) mallocarray(adapter->tx_num_queues, + sizeof(struct em_tx_queue), M_DEVBUF, M_NOWAIT | M_ZERO))) { + device_printf(iflib_get_dev(ctx), "Unable to allocate queue memory\n"); return(ENOMEM); } @@ -2849,7 +2849,8 @@ em_if_tx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, u que->me = txr->me = i; /* Allocate report status array */ - if (!(txr->tx_rsq = (qidx_t *) malloc(sizeof(qidx_t) * scctx->isc_ntxd[0], M_DEVBUF, M_NOWAIT | M_ZERO))) { + if (!(txr->tx_rsq = (qidx_t *) mallocarray(scctx->isc_ntxd[0], + sizeof(qidx_t), M_DEVBUF, M_NOWAIT | M_ZERO))) { device_printf(iflib_get_dev(ctx), "failed to allocate rs_idxs memory\n"); error = ENOMEM; goto fail; @@ -2881,8 +2882,8 @@ em_if_rx_queues_alloc(if_ctx_t ctx, caddr_t *vaddrs, u /* First allocate the top level queue structs */ if (!(adapter->rx_queues = - (struct em_rx_queue *) malloc(sizeof(struct em_rx_queue) * - adapter->rx_num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) { + (struct em_rx_queue *) mallocarray(adapter->rx_num_queues, + sizeof(struct em_rx_queue), M_DEVBUF, M_NOWAIT | M_ZERO))) { device_printf(iflib_get_dev(ctx), "Unable to allocate queue memory\n"); error = ENOMEM; goto fail; Modified: head/sys/dev/ixl/if_ixlv.c ============================================================================== --- head/sys/dev/ixl/if_ixlv.c Thu Jan 11 15:03:01 2018 (r327827) +++ head/sys/dev/ixl/if_ixlv.c Thu Jan 11 15:25:26 2018 (r327828) @@ -1637,8 +1637,8 @@ ixlv_setup_queues(struct ixlv_sc *sc) /* Get memory for the station queues */ if (!(vsi->queues = - (struct ixl_queue *) malloc(sizeof(struct ixl_queue) * - vsi->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) { + (struct ixl_queue *) mallocarray(vsi->num_queues, + sizeof(struct ixl_queue), M_DEVBUF, M_NOWAIT | M_ZERO))) { device_printf(dev, "Unable to allocate queue memory\n"); error = ENOMEM; goto early; Modified: head/sys/dev/ixl/ixl_pf_iov.c ============================================================================== --- head/sys/dev/ixl/ixl_pf_iov.c Thu Jan 11 15:03:01 2018 (r327827) +++ head/sys/dev/ixl/ixl_pf_iov.c Thu Jan 11 15:25:26 2018 (r327828) @@ -1695,8 +1695,8 @@ ixl_iov_init(device_t dev, uint16_t num_vfs, const nvl pf_vsi = &pf->vsi; IXL_PF_LOCK(pf); - pf->vfs = malloc(sizeof(struct ixl_vf) * num_vfs, M_IXL, M_NOWAIT | - M_ZERO); + pf->vfs = mallocarray(num_vfs, sizeof(struct ixl_vf), M_IXL, + M_NOWAIT | M_ZERO); if (pf->vfs == NULL) { error = ENOMEM; Modified: head/sys/dev/ixl/ixl_pf_main.c ============================================================================== --- head/sys/dev/ixl/ixl_pf_main.c Thu Jan 11 15:03:01 2018 (r327827) +++ head/sys/dev/ixl/ixl_pf_main.c Thu Jan 11 15:25:26 2018 (r327828) @@ -2431,8 +2431,8 @@ ixl_setup_stations(struct ixl_pf *pf) /* Get memory for the station queues */ if (!(vsi->queues = - (struct ixl_queue *) malloc(sizeof(struct ixl_queue) * - vsi->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO))) { + (struct ixl_queue *) mallocarray(vsi->num_queues, + sizeof(struct ixl_queue), M_DEVBUF, M_NOWAIT | M_ZERO))) { device_printf(dev, "Unable to allocate queue memory\n"); error = ENOMEM; return (error); @@ -3317,7 +3317,7 @@ ixl_add_hw_filters(struct ixl_vsi *vsi, int flags, int hw = &pf->hw; IXL_PF_LOCK_ASSERT(pf); - a = malloc(sizeof(struct i40e_aqc_add_macvlan_element_data) * cnt, + a = mallocarray(cnt, sizeof(struct i40e_aqc_add_macvlan_element_data), M_DEVBUF, M_NOWAIT | M_ZERO); if (a == NULL) { device_printf(dev, "add_hw_filters failed to get memory\n"); @@ -3380,7 +3380,8 @@ ixl_del_hw_filters(struct ixl_vsi *vsi, int cnt) hw = &pf->hw; dev = pf->dev; - d = malloc(sizeof(struct i40e_aqc_remove_macvlan_element_data) * cnt, + d = mallocarray(cnt, + sizeof(struct i40e_aqc_remove_macvlan_element_data), M_DEVBUF, M_NOWAIT | M_ZERO); if (d == NULL) { printf("del hw filter failed to get memory\n");