Re: [PATCH bpf-next] bpf: Return EINVAL instead of NULL for map_lookup_elem of queue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 6/8/24 2:29 AM, Florian Lehner wrote:
Programs should use map_peek_elem over map_lookup_elem for queues. NULL is
also not a valid queue return nor a proper error, that could be handled.

Signed-off-by: Florian Lehner <dev@xxxxxxxxxxx>

Acked-by: Yonghong Song <yonghong.song@xxxxxxxxx>

---
  kernel/bpf/queue_stack_maps.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/queue_stack_maps.c b/kernel/bpf/queue_stack_maps.c
index d869f51ea93a..85bead55024d 100644
--- a/kernel/bpf/queue_stack_maps.c
+++ b/kernel/bpf/queue_stack_maps.c
@@ -234,7 +234,8 @@ static long queue_stack_map_push_elem(struct bpf_map *map, void *value,
  /* Called from syscall or from eBPF program */
  static void *queue_stack_map_lookup_elem(struct bpf_map *map, void *key)
  {
-	return NULL;
+	/* The eBPF program should use map_peek_elem instead */
+	return ERR_PTR(-EINVAL);
  }
/* Called from syscall or from eBPF program */




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux