Skip to content

Commit 431ce83

Browse files
seehearfeelchenhuacai
authored andcommitted
LoongArch: Check return values for set_memory_{rw,rox}
set_memory_rw() and set_memory_rox() may fail, so we should check the return values and return immediately in larch_insn_text_copy(). Cc: stable@vger.kernel.org Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent a47f075 commit 431ce83

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

arch/loongarch/kernel/inst.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ static int text_copy_cb(void *data)
258258
int larch_insn_text_copy(void *dst, void *src, size_t len)
259259
{
260260
int ret = 0;
261+
int err = 0;
261262
size_t start, end;
262263
struct insn_copy copy = {
263264
.dst = dst,
@@ -275,9 +276,19 @@ int larch_insn_text_copy(void *dst, void *src, size_t len)
275276
start = round_down((size_t)dst, PAGE_SIZE);
276277
end = round_up((size_t)dst + len, PAGE_SIZE);
277278

278-
set_memory_rw(start, (end - start) / PAGE_SIZE);
279+
err = set_memory_rw(start, (end - start) / PAGE_SIZE);
280+
if (err) {
281+
pr_info("%s: set_memory_rw() failed\n", __func__);
282+
return err;
283+
}
284+
279285
ret = stop_machine_cpuslocked(text_copy_cb, &copy, cpu_online_mask);
280-
set_memory_rox(start, (end - start) / PAGE_SIZE);
286+
287+
err = set_memory_rox(start, (end - start) / PAGE_SIZE);
288+
if (err) {
289+
pr_info("%s: set_memory_rox() failed\n", __func__);
290+
return err;
291+
}
281292

282293
return ret;
283294
}

0 commit comments

Comments
 (0)