In practise none of our code-paths will use a NULL pointer so we might
as well enforce that. To stay aligned with the kernel behaviour update
our init_module() preload library to return EFAULT... Should we get
confused and pass NULL in the future.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
assert_cc(sizeof(uint32_t) == sizeof(Elf32_Word));
assert_cc(sizeof(uint32_t) == sizeof(Elf64_Word));
- if (!memory) {
- errno = -EINVAL;
- return NULL;
- }
-
elf = malloc(sizeof(struct kmod_elf));
if (elf == NULL) {
return NULL;
const char *symbol;
};
-struct kmod_elf *kmod_elf_new(const void *memory, off_t size);
+_nonnull_all_ struct kmod_elf *kmod_elf_new(const void *memory, off_t size);
_nonnull_all_ void kmod_elf_unref(struct kmod_elf *elf);
_must_check_ _nonnull_all_ const void *kmod_elf_get_memory(const struct kmod_elf *elf);
_must_check_ _nonnull_all_ int kmod_elf_get_modinfo_strings(const struct kmod_elf *elf, char ***array);
init_retcodes();
+ if (mem == NULL) {
+ errno = EFAULT;
+ return -1;
+ }
+
elf = kmod_elf_new(mem, len);
if (elf == NULL)
return -1;