From owner-svn-src-head@freebsd.org Mon Jan 15 21:15:26 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 AE728E774A7; Mon, 15 Jan 2018 21:15:26 +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 882C56EBDB; Mon, 15 Jan 2018 21:15:26 +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 A94D716939; Mon, 15 Jan 2018 21:15:25 +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 w0FLFPnb065951; Mon, 15 Jan 2018 21:15:25 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0FLFPLp065949; Mon, 15 Jan 2018 21:15:25 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201801152115.w0FLFPLp065949@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:15:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328022 - in head/sys/cam: . ctl X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: in head/sys/cam: . ctl X-SVN-Commit-Revision: 328022 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:15:26 -0000 Author: pfg Date: Mon Jan 15 21:15:25 2018 New Revision: 328022 URL: https://svnweb.freebsd.org/changeset/base/328022 Log: cam: 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. X-Differential revision: https://reviews.freebsd.org/D13837 Modified: head/sys/cam/cam_queue.c head/sys/cam/ctl/ctl_frontend.c Modified: head/sys/cam/cam_queue.c ============================================================================== --- head/sys/cam/cam_queue.c Mon Jan 15 21:14:56 2018 (r328021) +++ head/sys/cam/cam_queue.c Mon Jan 15 21:15:25 2018 (r328022) @@ -126,7 +126,7 @@ camq_resize(struct camq *queue, int new_size) KASSERT(new_size >= queue->entries, ("camq_resize: " "New queue size can't accommodate queued entries (%d < %d).", new_size, queue->entries)); - new_array = (cam_pinfo **)malloc(new_size * sizeof(cam_pinfo *), + new_array = (cam_pinfo **)mallocarray(new_size, sizeof(cam_pinfo *), M_CAMQ, M_NOWAIT); if (new_array == NULL) { /* Couldn't satisfy request */ Modified: head/sys/cam/ctl/ctl_frontend.c ============================================================================== --- head/sys/cam/ctl/ctl_frontend.c Mon Jan 15 21:14:56 2018 (r328021) +++ head/sys/cam/ctl/ctl_frontend.c Mon Jan 15 21:15:25 2018 (r328022) @@ -172,8 +172,8 @@ ctl_port_register(struct ctl_port *port) * Initialize the initiator and portname mappings */ port->max_initiators = CTL_MAX_INIT_PER_PORT; - port->wwpn_iid = malloc(sizeof(*port->wwpn_iid) * port->max_initiators, - M_CTL, M_NOWAIT | M_ZERO); + port->wwpn_iid = mallocarray(port->max_initiators, + sizeof(*port->wwpn_iid), M_CTL, M_NOWAIT | M_ZERO); if (port->wwpn_iid == NULL) { retval = ENOMEM; goto error;