* [PATCH v3 bpf] trace: bpf: Fix passing zero to PTR_ERR()
@ 2020-11-07 7:45 Wang Qing
2020-11-07 18:08 ` Yonghong Song
2020-11-09 21:18 ` John Fastabend
0 siblings, 2 replies; 3+ messages in thread
From: Wang Qing @ 2020-11-07 7:45 UTC (permalink / raw)
To: Steven Rostedt, Ingo Molnar, Alexei Starovoitov, Daniel Borkmann,
Martin KaFai Lau, Song Liu, Yonghong Song, Andrii Nakryiko,
John Fastabend, KP Singh, netdev, bpf, linux-kernel
Cc: Wang Qing
There is a bug when passing zero to PTR_ERR() and return.
Fix smatch err.
Signed-off-by: Wang Qing <wangqing@vivo.com>
---
kernel/trace/bpf_trace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 4517c8b..5113fd4
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1198,7 +1198,7 @@ static int bpf_btf_printf_prepare(struct btf_ptr *ptr, u32 btf_ptr_size,
*btf = bpf_get_btf_vmlinux();
if (IS_ERR_OR_NULL(*btf))
- return PTR_ERR(*btf);
+ return IS_ERR(*btf) ? PTR_ERR(*btf) : -EINVAL;
if (ptr->type_id > 0)
*btf_id = ptr->type_id;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3 bpf] trace: bpf: Fix passing zero to PTR_ERR()
2020-11-07 7:45 [PATCH v3 bpf] trace: bpf: Fix passing zero to PTR_ERR() Wang Qing
@ 2020-11-07 18:08 ` Yonghong Song
2020-11-09 21:18 ` John Fastabend
1 sibling, 0 replies; 3+ messages in thread
From: Yonghong Song @ 2020-11-07 18:08 UTC (permalink / raw)
To: Wang Qing, Steven Rostedt, Ingo Molnar, Alexei Starovoitov,
Daniel Borkmann, Martin KaFai Lau, Song Liu, Andrii Nakryiko,
John Fastabend, KP Singh, netdev, bpf, linux-kernel
On 11/6/20 11:45 PM, Wang Qing wrote:
> There is a bug when passing zero to PTR_ERR() and return.
> Fix smatch err.
>
> Signed-off-by: Wang Qing <wangqing@vivo.com>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v3 bpf] trace: bpf: Fix passing zero to PTR_ERR()
2020-11-07 7:45 [PATCH v3 bpf] trace: bpf: Fix passing zero to PTR_ERR() Wang Qing
2020-11-07 18:08 ` Yonghong Song
@ 2020-11-09 21:18 ` John Fastabend
1 sibling, 0 replies; 3+ messages in thread
From: John Fastabend @ 2020-11-09 21:18 UTC (permalink / raw)
To: Wang Qing, Steven Rostedt, Ingo Molnar, Alexei Starovoitov,
Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
Andrii Nakryiko, John Fastabend, KP Singh, netdev, bpf,
linux-kernel
Cc: Wang Qing
Wang Qing wrote:
> There is a bug when passing zero to PTR_ERR() and return.
> Fix smatch err.
>
> Signed-off-by: Wang Qing <wangqing@vivo.com>
> ---
> kernel/trace/bpf_trace.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 4517c8b..5113fd4
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -1198,7 +1198,7 @@ static int bpf_btf_printf_prepare(struct btf_ptr *ptr, u32 btf_ptr_size,
> *btf = bpf_get_btf_vmlinux();
>
> if (IS_ERR_OR_NULL(*btf))
> - return PTR_ERR(*btf);
> + return IS_ERR(*btf) ? PTR_ERR(*btf) : -EINVAL;
>
> if (ptr->type_id > 0)
> *btf_id = ptr->type_id;
> --
> 2.7.4
>
Acked-by: John Fastabend <john.fastabend@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-09 21:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-07 7:45 [PATCH v3 bpf] trace: bpf: Fix passing zero to PTR_ERR() Wang Qing
2020-11-07 18:08 ` Yonghong Song
2020-11-09 21:18 ` John Fastabend
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).