]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
bpf: Remove unnecessary loop in task_file_seq_get_next()
authorDan Carpenter <dan.carpenter@linaro.org>
Thu, 4 Jul 2024 15:19:19 +0000 (10:19 -0500)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 8 Jul 2024 14:23:19 +0000 (16:23 +0200)
After commit 0ede61d8589c ("file: convert to SLAB_TYPESAFE_BY_RCU") this
loop always iterates exactly one time.  Delete the for statement and pull
the code in a tab.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/bpf/ZoWJF51D4zWb6f5t@stanley.mountain
kernel/bpf/task_iter.c

index ec4e97c61eefe667955e984b934f354b9162b52d..02aa9db8d79616d3e0ebe62622a8738f41d34f28 100644 (file)
@@ -261,6 +261,7 @@ task_file_seq_get_next(struct bpf_iter_seq_task_file_info *info)
        u32 saved_tid = info->tid;
        struct task_struct *curr_task;
        unsigned int curr_fd = info->fd;
+       struct file *f;
 
        /* If this function returns a non-NULL file object,
         * it held a reference to the task/file.
@@ -286,12 +287,8 @@ again:
        }
 
        rcu_read_lock();
-       for (;; curr_fd++) {
-               struct file *f;
-               f = task_lookup_next_fdget_rcu(curr_task, &curr_fd);
-               if (!f)
-                       break;
-
+       f = task_lookup_next_fdget_rcu(curr_task, &curr_fd);
+       if (f) {
                /* set info->fd */
                info->fd = curr_fd;
                rcu_read_unlock();