From owner-svn-src-head@freebsd.org Thu Jan 11 15:44:04 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 703DAE6A82B; Thu, 11 Jan 2018 15:44:04 +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 4CB2376EA9; Thu, 11 Jan 2018 15:44:04 +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 A66B616F1F; Thu, 11 Jan 2018 15:44:03 +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 w0BFi3Ic092405; Thu, 11 Jan 2018 15:44:03 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0BFi3cs092402; Thu, 11 Jan 2018 15:44:03 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201801111544.w0BFi3cs092402@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:44:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327831 - in head/sys/dev/bhnd: bcma nvram siba X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: in head/sys/dev/bhnd: bcma nvram siba X-SVN-Commit-Revision: 327831 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:44:04 -0000 Author: pfg Date: Thu Jan 11 15:44:03 2018 New Revision: 327831 URL: https://svnweb.freebsd.org/changeset/base/327831 Log: dev/bhnd: Make use of mallocarray(9). This makes a calloc-like definition check for overflows as is common practice. Modified: head/sys/dev/bhnd/bcma/bcma_erom.c head/sys/dev/bhnd/nvram/bhnd_nvram_private.h head/sys/dev/bhnd/siba/siba_erom.c Modified: head/sys/dev/bhnd/bcma/bcma_erom.c ============================================================================== --- head/sys/dev/bhnd/bcma/bcma_erom.c Thu Jan 11 15:32:12 2018 (r327830) +++ head/sys/dev/bhnd/bcma/bcma_erom.c Thu Jan 11 15:44:03 2018 (r327831) @@ -400,7 +400,7 @@ bcma_erom_get_core_table(bhnd_erom_t *erom, struct bhn } /* Allocate our output buffer */ - buffer = malloc(sizeof(struct bhnd_core_info) * count, M_BHND, + buffer = mallocarray(count, sizeof(struct bhnd_core_info), M_BHND, M_NOWAIT); if (buffer == NULL) { error = ENOMEM; Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_private.h ============================================================================== --- head/sys/dev/bhnd/nvram/bhnd_nvram_private.h Thu Jan 11 15:32:12 2018 (r327830) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_private.h Thu Jan 11 15:44:03 2018 (r327831) @@ -74,7 +74,7 @@ MALLOC_DECLARE(M_BHND_NVRAM); #define bhnd_nv_toupper(c) toupper(c) #define bhnd_nv_malloc(size) malloc((size), M_BHND_NVRAM, M_NOWAIT) -#define bhnd_nv_calloc(n, size) malloc((n) * (size), M_BHND_NVRAM, \ +#define bhnd_nv_calloc(n, size) mallocarray((n), (size), M_BHND_NVRAM, \ M_NOWAIT | M_ZERO) #define bhnd_nv_reallocf(buf, size) reallocf((buf), (size), M_BHND_NVRAM, \ M_NOWAIT) Modified: head/sys/dev/bhnd/siba/siba_erom.c ============================================================================== --- head/sys/dev/bhnd/siba/siba_erom.c Thu Jan 11 15:32:12 2018 (r327830) +++ head/sys/dev/bhnd/siba/siba_erom.c Thu Jan 11 15:44:03 2018 (r327831) @@ -445,7 +445,7 @@ siba_erom_get_core_table(bhnd_erom_t *erom, struct bhn sc = (struct siba_erom *)erom; /* Allocate our core array */ - out = malloc(sizeof(*out) * sc->io.ncores, M_BHND, M_NOWAIT); + out = mallocarray(sc->io.ncores, sizeof(*out), M_BHND, M_NOWAIT); if (out == NULL) return (ENOMEM);