mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-18 15:30:21 +00:00
Remove useless checks for NULL before calling free(9), in the kernel
elf linkers. Found by: Related PVS-Studio diagnostic Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
86a448c3a4
commit
0be1e0e879
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=295489
@ -1090,12 +1090,9 @@ link_elf_load_file(linker_class_t cls, const char* filename,
|
||||
vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
|
||||
if (error != 0 && lf != NULL)
|
||||
linker_file_unload(lf, LINKER_UNLOAD_FORCE);
|
||||
if (shdr != NULL)
|
||||
free(shdr, M_LINKER);
|
||||
if (firstpage != NULL)
|
||||
free(firstpage, M_LINKER);
|
||||
if (shstrs != NULL)
|
||||
free(shstrs, M_LINKER);
|
||||
free(shdr, M_LINKER);
|
||||
free(firstpage, M_LINKER);
|
||||
free(shstrs, M_LINKER);
|
||||
|
||||
return (error);
|
||||
}
|
||||
@ -1157,19 +1154,13 @@ link_elf_unload_file(linker_file_t file)
|
||||
+ (ef->object->size << PAGE_SHIFT));
|
||||
}
|
||||
#else
|
||||
if (ef->address != NULL)
|
||||
free(ef->address, M_LINKER);
|
||||
free(ef->address, M_LINKER);
|
||||
#endif
|
||||
if (ef->symbase != NULL)
|
||||
free(ef->symbase, M_LINKER);
|
||||
if (ef->strbase != NULL)
|
||||
free(ef->strbase, M_LINKER);
|
||||
if (ef->ctftab != NULL)
|
||||
free(ef->ctftab, M_LINKER);
|
||||
if (ef->ctfoff != NULL)
|
||||
free(ef->ctfoff, M_LINKER);
|
||||
if (ef->typoff != NULL)
|
||||
free(ef->typoff, M_LINKER);
|
||||
free(ef->symbase, M_LINKER);
|
||||
free(ef->strbase, M_LINKER);
|
||||
free(ef->ctftab, M_LINKER);
|
||||
free(ef->ctfoff, M_LINKER);
|
||||
free(ef->typoff, M_LINKER);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -898,8 +898,7 @@ link_elf_load_file(linker_class_t cls, const char *filename,
|
||||
vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
|
||||
if (error && lf)
|
||||
linker_file_unload(lf, LINKER_UNLOAD_FORCE);
|
||||
if (hdr)
|
||||
free(hdr, M_LINKER);
|
||||
free(hdr, M_LINKER);
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -930,18 +929,12 @@ link_elf_unload_file(linker_file_t file)
|
||||
}
|
||||
}
|
||||
if (ef->preloaded) {
|
||||
if (ef->reltab)
|
||||
free(ef->reltab, M_LINKER);
|
||||
if (ef->relatab)
|
||||
free(ef->relatab, M_LINKER);
|
||||
if (ef->progtab)
|
||||
free(ef->progtab, M_LINKER);
|
||||
if (ef->ctftab)
|
||||
free(ef->ctftab, M_LINKER);
|
||||
if (ef->ctfoff)
|
||||
free(ef->ctfoff, M_LINKER);
|
||||
if (ef->typoff)
|
||||
free(ef->typoff, M_LINKER);
|
||||
free(ef->reltab, M_LINKER);
|
||||
free(ef->relatab, M_LINKER);
|
||||
free(ef->progtab, M_LINKER);
|
||||
free(ef->ctftab, M_LINKER);
|
||||
free(ef->ctfoff, M_LINKER);
|
||||
free(ef->typoff, M_LINKER);
|
||||
if (file->filename != NULL)
|
||||
preload_delete_name(file->filename);
|
||||
/* XXX reclaim module memory? */
|
||||
@ -949,37 +942,25 @@ link_elf_unload_file(linker_file_t file)
|
||||
}
|
||||
|
||||
for (i = 0; i < ef->nreltab; i++)
|
||||
if (ef->reltab[i].rel)
|
||||
free(ef->reltab[i].rel, M_LINKER);
|
||||
free(ef->reltab[i].rel, M_LINKER);
|
||||
for (i = 0; i < ef->nrelatab; i++)
|
||||
if (ef->relatab[i].rela)
|
||||
free(ef->relatab[i].rela, M_LINKER);
|
||||
if (ef->reltab)
|
||||
free(ef->reltab, M_LINKER);
|
||||
if (ef->relatab)
|
||||
free(ef->relatab, M_LINKER);
|
||||
if (ef->progtab)
|
||||
free(ef->progtab, M_LINKER);
|
||||
free(ef->relatab[i].rela, M_LINKER);
|
||||
free(ef->reltab, M_LINKER);
|
||||
free(ef->relatab, M_LINKER);
|
||||
free(ef->progtab, M_LINKER);
|
||||
|
||||
if (ef->object) {
|
||||
vm_map_remove(kernel_map, (vm_offset_t) ef->address,
|
||||
(vm_offset_t) ef->address +
|
||||
(ef->object->size << PAGE_SHIFT));
|
||||
}
|
||||
if (ef->e_shdr)
|
||||
free(ef->e_shdr, M_LINKER);
|
||||
if (ef->ddbsymtab)
|
||||
free(ef->ddbsymtab, M_LINKER);
|
||||
if (ef->ddbstrtab)
|
||||
free(ef->ddbstrtab, M_LINKER);
|
||||
if (ef->shstrtab)
|
||||
free(ef->shstrtab, M_LINKER);
|
||||
if (ef->ctftab)
|
||||
free(ef->ctftab, M_LINKER);
|
||||
if (ef->ctfoff)
|
||||
free(ef->ctfoff, M_LINKER);
|
||||
if (ef->typoff)
|
||||
free(ef->typoff, M_LINKER);
|
||||
free(ef->e_shdr, M_LINKER);
|
||||
free(ef->ddbsymtab, M_LINKER);
|
||||
free(ef->ddbstrtab, M_LINKER);
|
||||
free(ef->shstrtab, M_LINKER);
|
||||
free(ef->ctftab, M_LINKER);
|
||||
free(ef->ctfoff, M_LINKER);
|
||||
free(ef->typoff, M_LINKER);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
Loading…
Reference in New Issue
Block a user