From owner-svn-src-head@freebsd.org Mon Jan 15 21:23:17 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 38A6DE77D18; Mon, 15 Jan 2018 21:23:17 +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 144436F739; Mon, 15 Jan 2018 21:23:17 +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 6D54416AD4; Mon, 15 Jan 2018 21:23:16 +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 w0FLNGu0070171; Mon, 15 Jan 2018 21:23:16 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0FLNGPh070169; Mon, 15 Jan 2018 21:23:16 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201801152123.w0FLNGPh070169@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 15 Jan 2018 21:23:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328026 - in head/sys: geom/uzip gnu/dev/bwn/phy_n X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: in head/sys: geom/uzip gnu/dev/bwn/phy_n X-SVN-Commit-Revision: 328026 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: Mon, 15 Jan 2018 21:23:17 -0000 Author: pfg Date: Mon Jan 15 21:23:16 2018 New Revision: 328026 URL: https://svnweb.freebsd.org/changeset/base/328026 Log: misc geom and gnu: make some use of mallocarray(9). Focus on code where we are doing multiplications within malloc(9). None of these ire likely to overflow, however the change is still useful as some static checkers can benefit from the allocation attributes we use for mallocarray. This initial sweep only covers malloc(9) calls with M_NOWAIT. No good reason but I started doing the changes before r327796 and at that time it was convenient to make sure the sorrounding code could handle NULL values. Differential revision: https://reviews.freebsd.org/D13837 Modified: head/sys/geom/uzip/g_uzip_zlib.c head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c Modified: head/sys/geom/uzip/g_uzip_zlib.c ============================================================================== --- head/sys/geom/uzip/g_uzip_zlib.c Mon Jan 15 21:21:51 2018 (r328025) +++ head/sys/geom/uzip/g_uzip_zlib.c Mon Jan 15 21:23:16 2018 (r328026) @@ -132,7 +132,7 @@ z_alloc(void *nil, u_int type, u_int size) { void *ptr; - ptr = malloc(type * size, M_GEOM_UZIP, M_NOWAIT); + ptr = mallocarray(type, size, M_GEOM_UZIP, M_NOWAIT); return (ptr); } Modified: head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c ============================================================================== --- head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c Mon Jan 15 21:21:51 2018 (r328025) +++ head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c Mon Jan 15 21:23:16 2018 (r328026) @@ -1620,7 +1620,7 @@ static int bwn_nphy_load_samples(struct bwn_mac *mac, uint16_t i; uint32_t *data; - data = malloc(len * sizeof(uint32_t), M_DEVBUF, M_NOWAIT | M_ZERO); + data = mallocarray(len, sizeof(uint32_t), M_DEVBUF, M_NOWAIT | M_ZERO); if (!data) { BWN_ERRPRINTF(mac->mac_sc, "allocation for samples loading failed\n"); return -ENOMEM; @@ -1663,7 +1663,8 @@ static uint16_t bwn_nphy_gen_load_samples(struct bwn_m len = bw << 1; } - samples = malloc(len * sizeof(struct bwn_c32), M_DEVBUF, M_NOWAIT | M_ZERO); + samples = mallocarray(len, sizeof(struct bwn_c32), M_DEVBUF, + M_NOWAIT | M_ZERO); if (!samples) { BWN_ERRPRINTF(mac->mac_sc, "allocation for samples generation failed\n"); return 0;