Message ID | 20220512141710.116135-3-wanjiabing@vivo.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | BPF |
Headers | show |
Series | bpf: optimize the bpf_kprobe_multi_link_attach function | expand |
Context | Check | Description |
---|---|---|
bpf/vmtest-bpf-next-VM_Test-2 | success | Logs for Kernel LATEST on z15 + selftests |
bpf/vmtest-bpf-next-PR | fail | PR summary |
bpf/vmtest-bpf-next-VM_Test-1 | fail | Logs for Kernel LATEST on ubuntu-latest + selftests |
netdev/tree_selection | success | Guessing tree name failed - patch did not apply |
> On May 12, 2022, at 7:17 AM, Wan Jiabing <wanjiabing@vivo.com> wrote: > > Simplify double 'if' statements to one 'if' statement. > > Signed-off-by: Wan Jiabing <wanjiabing@vivo.com> > --- > kernel/trace/bpf_trace.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c > index 3a8b69ef9a0d..1b0db8f78dc8 100644 > --- a/kernel/trace/bpf_trace.c > +++ b/kernel/trace/bpf_trace.c > @@ -2464,11 +2464,9 @@ int bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr > if (!addrs) > return -ENOMEM; > > - if (uaddrs) { > - if (copy_from_user(addrs, uaddrs, size)) { > - err = -EFAULT; > - goto error_addrs; > - } > + if (uaddrs && copy_from_user(addrs, uaddrs, size)) { > + err = -EFAULT; > + goto error_addrs; > } else { > struct user_syms us; This changed the behavior, no? For uaddrs != NULL and copy_from_user() == 0 case, we now going into else clause. Did I misread anything? Song
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 3a8b69ef9a0d..1b0db8f78dc8 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -2464,11 +2464,9 @@ int bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr if (!addrs) return -ENOMEM; - if (uaddrs) { - if (copy_from_user(addrs, uaddrs, size)) { - err = -EFAULT; - goto error_addrs; - } + if (uaddrs && copy_from_user(addrs, uaddrs, size)) { + err = -EFAULT; + goto error_addrs; } else { struct user_syms us;
Simplify double 'if' statements to one 'if' statement. Signed-off-by: Wan Jiabing <wanjiabing@vivo.com> --- kernel/trace/bpf_trace.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)