Commit f7f18e30 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/kprobes: Handle error returned by set_memory_rox()

set_memory_rox() can fail.

In case it fails, free allocated memory and return NULL.

Link: https://github.com/KSPP/linux/issues/7Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/b4907cf4339bd086abc40430d91311436cb0c18e.1708078401.git.christophe.leroy@csgroup.eu
parent 09ca1b11
......@@ -134,10 +134,16 @@ void *alloc_insn_page(void)
if (!page)
return NULL;
if (strict_module_rwx_enabled())
set_memory_rox((unsigned long)page, 1);
if (strict_module_rwx_enabled()) {
int err = set_memory_rox((unsigned long)page, 1);
if (err)
goto error;
}
return page;
error:
module_memfree(page);
return NULL;
}
int arch_prepare_kprobe(struct kprobe *p)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment