* [PATCH 1/2] bpf: Fix warning of Using plain integer as NULL pointer
@ 2022-09-03 18:56 Jules Irenge
2022-09-03 19:10 ` Kumar Kartikeya Dwivedi
0 siblings, 1 reply; 3+ messages in thread
From: Jules Irenge @ 2022-09-03 18:56 UTC (permalink / raw)
To: ast
Cc: john.fastabend, andrii, daniel, bpf, linux-kernel, martin.lau,
jbi.octave
This patch fixes a warning generated by Sparse
"Using plain integer as NULL pointer"
by replacing the offending 0 by NULL.
Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
kernel/bpf/syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 27760627370d..427b7e3829e0 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -598,7 +598,7 @@ void bpf_map_free_kptrs(struct bpf_map *map, void *map_value)
if (off_desc->type == BPF_KPTR_UNREF) {
u64 *p = (u64 *)btf_id_ptr;
- WRITE_ONCE(p, 0);
+ WRITE_ONCE(p, NULL);
continue;
}
old_ptr = xchg(btf_id_ptr, 0);
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] bpf: Fix warning of Using plain integer as NULL pointer
2022-09-03 18:56 [PATCH 1/2] bpf: Fix warning of Using plain integer as NULL pointer Jules Irenge
@ 2022-09-03 19:10 ` Kumar Kartikeya Dwivedi
2022-09-04 10:36 ` Jules Irenge
0 siblings, 1 reply; 3+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2022-09-03 19:10 UTC (permalink / raw)
To: Jules Irenge
Cc: ast, john.fastabend, andrii, daniel, bpf, linux-kernel,
martin.lau
On Sat, 3 Sept 2022 at 20:59, Jules Irenge <jbi.octave@gmail.com> wrote:
>
> This patch fixes a warning generated by Sparse
>
> "Using plain integer as NULL pointer"
>
> by replacing the offending 0 by NULL.
>
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> ---
> kernel/bpf/syscall.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 27760627370d..427b7e3829e0 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -598,7 +598,7 @@ void bpf_map_free_kptrs(struct bpf_map *map, void *map_value)
> if (off_desc->type == BPF_KPTR_UNREF) {
> u64 *p = (u64 *)btf_id_ptr;
>
> - WRITE_ONCE(p, 0);
> + WRITE_ONCE(p, NULL);
Uff, this should have been WRITE_ONCE(*p, 0) instead. Mea Culpa.
Can you make that fix? It's not a big problem since it's just that the
pointer won't be cleared on map value delete (and there is nothing to
reclaim for the unref case when map is freed), so you can target
bpf-next with a Fixes tag.
So in your patch you will need [PATCH bpf-next] in the subject and the
fixes tag would be:
Fixes: 14a324f6a67e ("bpf: Wire up freeing of referenced kptr")
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] bpf: Fix warning of Using plain integer as NULL pointer
2022-09-03 19:10 ` Kumar Kartikeya Dwivedi
@ 2022-09-04 10:36 ` Jules Irenge
0 siblings, 0 replies; 3+ messages in thread
From: Jules Irenge @ 2022-09-04 10:36 UTC (permalink / raw)
To: Kumar Kartikeya Dwivedi; +Cc: bpf, linux-kernel, john.fastabend, ast
On Sat, Sep 03, 2022 at 09:10:31PM +0200, Kumar Kartikeya Dwivedi wrote:
> On Sat, 3 Sept 2022 at 20:59, Jules Irenge <jbi.octave@gmail.com> wrote:
> >
> > This patch fixes a warning generated by Sparse
> >
> > "Using plain integer as NULL pointer"
> >
> > by replacing the offending 0 by NULL.
> >
> > Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> > ---
> > kernel/bpf/syscall.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> > index 27760627370d..427b7e3829e0 100644
> > --- a/kernel/bpf/syscall.c
> > +++ b/kernel/bpf/syscall.c
> > @@ -598,7 +598,7 @@ void bpf_map_free_kptrs(struct bpf_map *map, void *map_value)
> > if (off_desc->type == BPF_KPTR_UNREF) {
> > u64 *p = (u64 *)btf_id_ptr;
> >
> > - WRITE_ONCE(p, 0);
> > + WRITE_ONCE(p, NULL);
>
> Uff, this should have been WRITE_ONCE(*p, 0) instead. Mea Culpa.
> Can you make that fix? It's not a big problem since it's just that the
> pointer won't be cleared on map value delete (and there is nothing to
> reclaim for the unref case when map is freed), so you can target
> bpf-next with a Fixes tag.
> So in your patch you will need [PATCH bpf-next] in the subject and the
> fixes tag would be:
> Fixes: 14a324f6a67e ("bpf: Wire up freeing of referenced kptr")
Thanks, already done. if there is anything I miss, please let me know. I am on a learning
journey.
Jules
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-04 10:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-03 18:56 [PATCH 1/2] bpf: Fix warning of Using plain integer as NULL pointer Jules Irenge
2022-09-03 19:10 ` Kumar Kartikeya Dwivedi
2022-09-04 10:36 ` Jules Irenge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox