Skip to content

Commit 361fc04

Browse files
chenhengqiKernel Patches Daemon
authored andcommitted
LoongArch: BPF: Make error handling robust in arch_prepare_bpf_trampoline()
Bail out instead of trying to perform a bpf_arch_text_copy() if __arch_prepare_bpf_trampoline() failed. Signed-off-by: Hengqi Chen <[email protected]>
1 parent b8574f8 commit 361fc04

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/loongarch/net/bpf_jit.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,10 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *ro_image,
17191719

17201720
jit_fill_hole(image, (unsigned int)(ro_image_end - ro_image));
17211721
ret = __arch_prepare_bpf_trampoline(&ctx, im, m, tlinks, func_addr, flags);
1722-
if (ret > 0 && validate_code(&ctx) < 0) {
1722+
if (ret < 0)
1723+
goto out;
1724+
1725+
if (validate_code(&ctx) < 0) {
17231726
ret = -EINVAL;
17241727
goto out;
17251728
}

0 commit comments

Comments
 (0)