]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bpf: Use ERR_CAST instead of ERR_PTR(PTR_ERR(...))
authorYonghong Song <yonghong.song@linux.dev>
Sun, 20 Jul 2025 16:47:54 +0000 (09:47 -0700)
committerMartin KaFai Lau <martin.lau@kernel.org>
Tue, 22 Jul 2025 00:27:09 +0000 (17:27 -0700)
Intel linux test robot reported a warning that ERR_CAST can be used
for error pointer casting instead of more-complicated/rarely-used
ERR_PTR(PTR_ERR(...)) style.

There is no functionality change, but still let us replace two such
instances as it improves consistency and readability.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202507201048.bceHy8zX-lkp@intel.com/
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://patch.msgid.link/20250720164754.3999140-1-yonghong.song@linux.dev
kernel/bpf/cgroup.c

index 72c8b50dca0ac94ad239486ef357a7619677035d..2e1c0eab20c007e6a84883788e598a6044815160 100644 (file)
@@ -707,11 +707,11 @@ static struct bpf_prog_list *get_prog_list(struct hlist_head *progs, struct bpf_
        if (is_link) {
                anchor_link = bpf_get_anchor_link(flags, id_or_fd);
                if (IS_ERR(anchor_link))
-                       return ERR_PTR(PTR_ERR(anchor_link));
+                       return ERR_CAST(anchor_link);
        } else if (is_id || id_or_fd) {
                anchor_prog = bpf_get_anchor_prog(flags, id_or_fd);
                if (IS_ERR(anchor_prog))
-                       return ERR_PTR(PTR_ERR(anchor_prog));
+                       return ERR_CAST(anchor_prog);
        }
 
        if (!anchor_prog && !anchor_link) {