]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bpf: Simplify assignment to struct bpf_insn pointer in do_misc_fixups()
authorYonghong Song <yonghong.song@linux.dev>
Thu, 3 Jul 2025 14:11:06 +0000 (07:11 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 4 Jul 2025 02:31:29 +0000 (19:31 -0700)
In verifier.c, the following code patterns (in two places)
  struct bpf_insn *patch = &insn_buf[0];
can be simplified to
  struct bpf_insn *patch = insn_buf;
which is easier to understand.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20250703141106.1483216-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c

index 29e0dddc22f836187c6cda5dc491d82373eca8a9..3ecb91c7e4f87a30c730d029538e0d4fbd860734 100644 (file)
@@ -22103,7 +22103,7 @@ static int do_misc_fixups(struct bpf_verifier_env *env)
                if (BPF_CLASS(insn->code) == BPF_LDX &&
                    (BPF_MODE(insn->code) == BPF_PROBE_MEM ||
                     BPF_MODE(insn->code) == BPF_PROBE_MEMSX)) {
-                       struct bpf_insn *patch = &insn_buf[0];
+                       struct bpf_insn *patch = insn_buf;
                        u64 uaddress_limit = bpf_arch_uaddress_limit();
 
                        if (!uaddress_limit)
@@ -22154,7 +22154,7 @@ static int do_misc_fixups(struct bpf_verifier_env *env)
                    insn->code == (BPF_ALU64 | BPF_SUB | BPF_X)) {
                        const u8 code_add = BPF_ALU64 | BPF_ADD | BPF_X;
                        const u8 code_sub = BPF_ALU64 | BPF_SUB | BPF_X;
-                       struct bpf_insn *patch = &insn_buf[0];
+                       struct bpf_insn *patch = insn_buf;
                        bool issrc, isneg, isimm;
                        u32 off_reg;