create-diff-object: check mallor retval in kpatch_create_mcount_sections()

newdata variable is allocated through malloc call and requires a NULL
check.

Found by covscan, see issue #984 for full log.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
This commit is contained in:
Artem Savkov 2019-07-31 13:58:20 +02:00
parent deb7719280
commit dba95bae62

View File

@ -3156,6 +3156,9 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf)
* __fentry__" so that ftrace will be happy.
*/
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;