Skip to content

Commit de2c0b7

Browse files
chenhengqichenhuacai
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. Cc: stable@vger.kernel.org Tested-by: Vincent Li <vincent.mc.li@gmail.com> Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent ea645cf commit de2c0b7

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
@@ -1715,7 +1715,10 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *ro_image,
17151715

17161716
jit_fill_hole(image, (unsigned int)(ro_image_end - ro_image));
17171717
ret = __arch_prepare_bpf_trampoline(&ctx, im, m, tlinks, func_addr, flags);
1718-
if (ret > 0 && validate_code(&ctx) < 0) {
1718+
if (ret < 0)
1719+
goto out;
1720+
1721+
if (validate_code(&ctx) < 0) {
17191722
ret = -EINVAL;
17201723
goto out;
17211724
}

0 commit comments

Comments
 (0)