]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: fix potential error return
authorAnton Protopopov <aspsk@isovalent.com>
Tue, 10 Dec 2024 11:42:45 +0000 (11:42 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2025 12:28:49 +0000 (13:28 +0100)
commitcc63b8c102c4fa26aa65bceb9a244ea7e23d2129
tree52bfc0fda8538ffa1de22907f8cb4b1dd8537d35
parent2dedcab091f26e9ae617652cff109fc468c1ee38
bpf: fix potential error return

[ Upstream commit c4441ca86afe4814039ee1b32c39d833c1a16bbc ]

The bpf_remove_insns() function returns WARN_ON_ONCE(error), where
error is a result of bpf_adj_branches(), and thus should be always 0
However, if for any reason it is not 0, then it will be converted to
boolean by WARN_ON_ONCE and returned to user space as 1, not an actual
error value. Fix this by returning the original err after the WARN check.

Signed-off-by: Anton Protopopov <aspsk@isovalent.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20241210114245.836164-1-aspsk@isovalent.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/core.c