1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Remove malloc(9) return value checks when M_WAITOK is used.

MFC after:	2 Week
This commit is contained in:
Dmitry Chagin 2011-04-16 16:20:51 +00:00
parent 9dd0e40b62
commit fa2835d296
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=220730
2 changed files with 0 additions and 44 deletions

View File

@ -692,10 +692,6 @@ link_elf_load_file(linker_class_t cls, const char* filename,
* 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, const char* filename,
}
#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, const char* filename,
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, const char* filename,
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, const char *name,
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);

View File

@ -476,10 +476,6 @@ link_elf_load_file(linker_class_t cls, const char *filename,
/* 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, const char *filename,
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, const char *filename,
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, const char *filename,
/* 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, const char *filename,
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,