Merge pull request #1246 from Decave/malloc_failure_check

kpatch-build: Add missing malloc failure check
This commit is contained in:
Joe Lawrence 2022-01-17 11:44:02 -05:00 committed by GitHub
commit b65fce5e07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -911,6 +911,8 @@ do { \
log_debug("renaming %s %s to %s\n", \
kindstr, e2->name, e1->name); \
e2->name = strdup(e1->name); \
if (!e2->name) \
ERROR("strdup"); \
} \
} while (0)
@ -3461,6 +3463,8 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf)
/* Make a writable copy of the text section data */
newdata = malloc(sym->sec->data->d_size);
if (!newdata)
ERROR("malloc");
memcpy(newdata, sym->sec->data->d_buf, sym->sec->data->d_size);
sym->sec->data->d_buf = newdata;
insn = newdata;

View File

@ -326,6 +326,8 @@ static void create_klp_arch_sections(struct kpatch_elf *kelf, char *strings)
new_size = old_size + base->data->d_size;
sec->data->d_buf = realloc(sec->data->d_buf, new_size);
if (!sec->data->d_buf)
ERROR("realloc");
sec->data->d_size = new_size;
sec->sh.sh_size = sec->data->d_size;
memcpy(sec->data->d_buf + old_size,