bpf: Fix warning of Using plain integer as NULL pointer
PATCH 1/2 bpf: Fix warning of Using plain integer as NULL pointer
This patch fixes a warning generated by Sparse
"Using plain integer as NULL pointer"
by replacing the offending 0 by NULL.
--- kernel/bpf/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/syscall.c +1 -1
@@ -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 );
Signature · 1 line
2.35.1
Kumar Kartikeya Dwivedi
maintainerQuoted 17 lines · Jules Irenge
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 <[email protected]>--- kernel/bpf/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/bpf/syscall.c +0
-0
kernel/bpf/syscall.c void bpf_map_free_kptrs(struct bpf_map *map, void *map_value) · line 601
Quoted 5 lines
kernel/bpf/syscall.c +1
-1@@ -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:
Quoted 31 lines · Kumar Kartikeya Dwivedi
Quoted 17 lines · Jules Irenge
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 <[email protected]>--- kernel/bpf/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/bpf/syscall.c +0
-0kernel/bpf/syscall.c void bpf_map_free_kptrs(struct bpf_map *map, void *map_value) · line 601
Quoted 5 lines
kernel/bpf/syscall.c +1
-1@@ -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:
Quoted 1 line
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