From owner-svn-src-all@FreeBSD.ORG Wed Mar 19 13:02:28 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 18C7293C; Wed, 19 Mar 2014 13:02:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DF3AD298; Wed, 19 Mar 2014 13:02:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2JD2RfU040904; Wed, 19 Mar 2014 13:02:27 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2JD2Rbv040899; Wed, 19 Mar 2014 13:02:27 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201403191302.s2JD2Rbv040899@svn.freebsd.org> From: Konstantin Belousov Date: Wed, 19 Mar 2014 13:02:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r263358 - in stable/9/sys: dev/cpuctl dev/hwpmc kern X-SVN-Group: stable-9 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.17 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: Wed, 19 Mar 2014 13:02:28 -0000 Author: kib Date: Wed Mar 19 13:02:26 2014 New Revision: 263358 URL: http://svnweb.freebsd.org/changeset/base/263358 Log: MFC r263080: Use correct types for sizeof() in the calculations for the malloc(9) sizes. Modified: stable/9/sys/dev/cpuctl/cpuctl.c stable/9/sys/dev/hwpmc/hwpmc_piv.c stable/9/sys/kern/kern_linker.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/cpuctl/cpuctl.c ============================================================================== --- stable/9/sys/dev/cpuctl/cpuctl.c Wed Mar 19 13:02:17 2014 (r263357) +++ stable/9/sys/dev/cpuctl/cpuctl.c Wed Mar 19 13:02:26 2014 (r263358) @@ -510,13 +510,8 @@ cpuctl_modevent(module_t mod __unused, i } if (bootverbose) printf("cpuctl: access to MSR registers/cpuid info.\n"); - cpuctl_devs = (struct cdev **)malloc(sizeof(void *) * mp_ncpus, - M_CPUCTL, M_WAITOK | M_ZERO); - if (cpuctl_devs == NULL) { - DPRINTF("[cpuctl,%d]: cannot allocate memory\n", - __LINE__); - return (ENOMEM); - } + cpuctl_devs = malloc(sizeof(*cpuctl_devs) * mp_ncpus, M_CPUCTL, + M_WAITOK | M_ZERO); for (cpu = 0; cpu < mp_ncpus; cpu++) if (cpu_enabled(cpu)) cpuctl_devs[cpu] = make_dev(&cpuctl_cdevsw, cpu, Modified: stable/9/sys/dev/hwpmc/hwpmc_piv.c ============================================================================== --- stable/9/sys/dev/hwpmc/hwpmc_piv.c Wed Mar 19 13:02:17 2014 (r263357) +++ stable/9/sys/dev/hwpmc/hwpmc_piv.c Wed Mar 19 13:02:26 2014 (r263358) @@ -1620,8 +1620,7 @@ pmc_p4_initialize(struct pmc_mdep *md, i PMCDBG(MDP,INI,1, "%s", "p4-initialize"); /* Allocate space for pointers to per-cpu descriptors. */ - p4_pcpu = malloc(sizeof(struct p4_cpu **) * ncpus, M_PMC, - M_ZERO|M_WAITOK); + p4_pcpu = malloc(sizeof(*p4_pcpu) * ncpus, M_PMC, M_ZERO | M_WAITOK); /* Fill in the class dependent descriptor. */ pcd = &md->pmd_classdep[PMC_MDEP_CLASS_INDEX_P4]; Modified: stable/9/sys/kern/kern_linker.c ============================================================================== --- stable/9/sys/kern/kern_linker.c Wed Mar 19 13:02:17 2014 (r263357) +++ stable/9/sys/kern/kern_linker.c Wed Mar 19 13:02:26 2014 (r263358) @@ -733,14 +733,11 @@ linker_file_add_dependency(linker_file_t linker_file_t *newdeps; sx_assert(&kld_sx, SA_XLOCKED); - newdeps = malloc((file->ndeps + 1) * sizeof(linker_file_t *), - M_LINKER, M_WAITOK | M_ZERO); - if (newdeps == NULL) - return (ENOMEM); + newdeps = malloc((file->ndeps + 1) * sizeof(*newdeps), M_LINKER, + M_WAITOK | M_ZERO); if (file->deps) { - bcopy(file->deps, newdeps, - file->ndeps * sizeof(linker_file_t *)); + bcopy(file->deps, newdeps, file->ndeps * sizeof(*newdeps)); free(file->deps, M_LINKER); } file->deps = newdeps;