From owner-svn-src-all@freebsd.org Mon Jan 22 15:55:52 2018 Return-Path: Delivered-To: svn-src-all@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 CF751EC7CEC; Mon, 22 Jan 2018 15:55:52 +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 AAADB822FC; Mon, 22 Jan 2018 15:55:52 +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 E8B141C47B; Mon, 22 Jan 2018 15:55:51 +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 w0MFtpEX014957; Mon, 22 Jan 2018 15:55:51 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0MFtpeU014956; Mon, 22 Jan 2018 15:55:51 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201801221555.w0MFtpeU014956@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 22 Jan 2018 15:55:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328261 - head/sys/dev/drm2 X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: head/sys/dev/drm2 X-SVN-Commit-Revision: 328261 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jan 2018 15:55:52 -0000 Author: pfg Date: Mon Jan 22 15:55:51 2018 New Revision: 328261 URL: https://svnweb.freebsd.org/changeset/base/328261 Log: drm2: Basic use of mallocarray(9). These functions deal the same type of overflows we do with mallocarray(9). Using our mallocarray will panic, which different from the previous behavior (returning NULL), but neither behavior is more correct. As a sidenote, drm_calloc_large() is not currently used at all. Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D13835 Modified: head/sys/dev/drm2/drm_mem_util.h Modified: head/sys/dev/drm2/drm_mem_util.h ============================================================================== --- head/sys/dev/drm2/drm_mem_util.h Mon Jan 22 08:33:59 2018 (r328260) +++ head/sys/dev/drm2/drm_mem_util.h Mon Jan 22 15:55:51 2018 (r328261) @@ -36,19 +36,15 @@ __FBSDID("$FreeBSD$"); static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) { - if (size != 0 && nmemb > SIZE_MAX / size) - return NULL; - return malloc(nmemb * size, DRM_MEM_DRIVER, M_NOWAIT | M_ZERO); + return mallocarray(nmemb, size, DRM_MEM_DRIVER, M_NOWAIT | M_ZERO); } /* Modeled after cairo's malloc_ab, it's like calloc but without the zeroing. */ static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size) { - if (size != 0 && nmemb > SIZE_MAX / size) - return NULL; - return malloc(nmemb * size, DRM_MEM_DRIVER, M_NOWAIT); + return mallocarray(nmemb, size, DRM_MEM_DRIVER, M_NOWAIT); } static __inline void drm_free_large(void *ptr)