From owner-svn-src-all@FreeBSD.ORG Sat Apr 16 16:20:52 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 44933106564A; Sat, 16 Apr 2011 16:20:52 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 324D78FC0A; Sat, 16 Apr 2011 16:20:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GGKqQl010594; Sat, 16 Apr 2011 16:20:52 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GGKqc2010591; Sat, 16 Apr 2011 16:20:52 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104161620.p3GGKqc2010591@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 16 Apr 2011 16:20:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220730 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Sat, 16 Apr 2011 16:20:52 -0000 Author: dchagin Date: Sat Apr 16 16:20:51 2011 New Revision: 220730 URL: http://svn.freebsd.org/changeset/base/220730 Log: Remove malloc(9) return value checks when M_WAITOK is used. MFC after: 2 Week Modified: head/sys/kern/link_elf.c head/sys/kern/link_elf_obj.c Modified: head/sys/kern/link_elf.c ============================================================================== --- head/sys/kern/link_elf.c Sat Apr 16 14:56:13 2011 (r220729) +++ head/sys/kern/link_elf.c Sat Apr 16 16:20:51 2011 (r220730) @@ -692,10 +692,6 @@ link_elf_load_file(linker_class_t cls, c * Read the elf header from the file. */ firstpage = malloc(PAGE_SIZE, M_LINKER, M_WAITOK); - if (firstpage == NULL) { - error = ENOMEM; - goto out; - } hdr = (Elf_Ehdr *)firstpage; error = vn_rdwr(UIO_READ, nd.ni_vp, firstpage, PAGE_SIZE, 0, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, @@ -829,10 +825,6 @@ link_elf_load_file(linker_class_t cls, c } #else ef->address = malloc(mapsize, M_LINKER, M_WAITOK); - if (ef->address == NULL) { - error = ENOMEM; - goto out; - } #endif mapbase = ef->address; @@ -918,10 +910,6 @@ link_elf_load_file(linker_class_t cls, c if (nbytes == 0 || hdr->e_shoff == 0) goto nosyms; shdr = malloc(nbytes, M_LINKER, M_WAITOK | M_ZERO); - if (shdr == NULL) { - error = ENOMEM; - goto out; - } error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)shdr, nbytes, hdr->e_shoff, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, @@ -944,10 +932,6 @@ link_elf_load_file(linker_class_t cls, c strcnt = shdr[symstrindex].sh_size; ef->strbase = malloc(strcnt, M_LINKER, M_WAITOK); - if (ef->symbase == NULL || ef->strbase == NULL) { - error = ENOMEM; - goto out; - } error = vn_rdwr(UIO_READ, nd.ni_vp, ef->symbase, symcnt, shdr[symtabindex].sh_offset, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, @@ -1318,8 +1302,6 @@ link_elf_lookup_set(linker_file_t lf, co len = strlen(name) + sizeof("__start_set_"); /* sizeof includes \0 */ setsym = malloc(len, M_LINKER, M_WAITOK); - if (setsym == NULL) - return (ENOMEM); /* get address of first entry */ snprintf(setsym, len, "%s%s", "__start_set_", name); Modified: head/sys/kern/link_elf_obj.c ============================================================================== --- head/sys/kern/link_elf_obj.c Sat Apr 16 14:56:13 2011 (r220729) +++ head/sys/kern/link_elf_obj.c Sat Apr 16 16:20:51 2011 (r220730) @@ -476,10 +476,6 @@ link_elf_load_file(linker_class_t cls, c /* Read the elf header from the file. */ hdr = malloc(sizeof(*hdr), M_LINKER, M_WAITOK); - if (hdr == NULL) { - error = ENOMEM; - goto out; - } error = vn_rdwr(UIO_READ, nd.ni_vp, (void *)hdr, sizeof(*hdr), 0, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, &resid, td); @@ -536,10 +532,6 @@ link_elf_load_file(linker_class_t cls, c goto out; } shdr = malloc(nbytes, M_LINKER, M_WAITOK); - if (shdr == NULL) { - error = ENOMEM; - goto out; - } ef->e_shdr = shdr; error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)shdr, nbytes, hdr->e_shoff, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, &resid, td); @@ -605,22 +597,12 @@ link_elf_load_file(linker_class_t cls, c if (ef->nrelatab != 0) ef->relatab = malloc(ef->nrelatab * sizeof(*ef->relatab), M_LINKER, M_WAITOK | M_ZERO); - if ((ef->nprogtab != 0 && ef->progtab == NULL) || - (ef->nreltab != 0 && ef->reltab == NULL) || - (ef->nrelatab != 0 && ef->relatab == NULL)) { - error = ENOMEM; - goto out; - } if (symtabindex == -1) panic("lost symbol table index"); /* Allocate space for and load the symbol table */ ef->ddbsymcnt = shdr[symtabindex].sh_size / sizeof(Elf_Sym); ef->ddbsymtab = malloc(shdr[symtabindex].sh_size, M_LINKER, M_WAITOK); - if (ef->ddbsymtab == NULL) { - error = ENOMEM; - goto out; - } error = vn_rdwr(UIO_READ, nd.ni_vp, (void *)ef->ddbsymtab, shdr[symtabindex].sh_size, shdr[symtabindex].sh_offset, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, @@ -637,10 +619,6 @@ link_elf_load_file(linker_class_t cls, c /* Allocate space for and load the symbol strings */ ef->ddbstrcnt = shdr[symstrindex].sh_size; ef->ddbstrtab = malloc(shdr[symstrindex].sh_size, M_LINKER, M_WAITOK); - if (ef->ddbstrtab == NULL) { - error = ENOMEM; - goto out; - } error = vn_rdwr(UIO_READ, nd.ni_vp, ef->ddbstrtab, shdr[symstrindex].sh_size, shdr[symstrindex].sh_offset, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, @@ -660,10 +638,6 @@ link_elf_load_file(linker_class_t cls, c ef->shstrcnt = shdr[shstrindex].sh_size; ef->shstrtab = malloc(shdr[shstrindex].sh_size, M_LINKER, M_WAITOK); - if (ef->shstrtab == NULL) { - error = ENOMEM; - goto out; - } error = vn_rdwr(UIO_READ, nd.ni_vp, ef->shstrtab, shdr[shstrindex].sh_size, shdr[shstrindex].sh_offset, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,