diff mbox series

[net] netfilter: nft_socket: Fix a NULL vs IS_ERR() bug in nft_socket_cgroup_subtree_level()

Message ID bbc0c4e0-05cc-4f44-8797-2f4b3920a820@stanley.mountain (mailing list archive)
State Accepted
Commit 7052622fccb1efb850c6b55de477f65d03525a30
Delegated to: Netdev Maintainers
Headers show
Series [net] netfilter: nft_socket: Fix a NULL vs IS_ERR() bug in nft_socket_cgroup_subtree_level() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-09-14--15-00 (tests: 764)

Commit Message

Dan Carpenter Sept. 14, 2024, 9:56 a.m. UTC
The cgroup_get_from_path() function never returns NULL, it returns error
pointers.  Update the error handling to match.

Fixes: 7f3287db6543 ("netfilter: nft_socket: make cgroupsv2 matching work with namespaces")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 net/netfilter/nft_socket.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Florian Westphal Sept. 14, 2024, 11:19 a.m. UTC | #1
Dan Carpenter <dan.carpenter@linaro.org> wrote:
> The cgroup_get_from_path() function never returns NULL, it returns error
> pointers.  Update the error handling to match.

Good news, I will retire in the next few years so I don't send shit
patches anymore.

Acked-by: Florian Westphal <fw@strlen.de>
Simon Horman Sept. 14, 2024, 3:21 p.m. UTC | #2
On Sat, Sep 14, 2024 at 01:19:40PM +0200, Florian Westphal wrote:
> Dan Carpenter <dan.carpenter@linaro.org> wrote:
> > The cgroup_get_from_path() function never returns NULL, it returns error
> > pointers.  Update the error handling to match.
> 
> Good news, I will retire in the next few years so I don't send shit
> patches anymore.
> 
> Acked-by: Florian Westphal <fw@strlen.de>

Everyone makes mistakes, don't be too hard on yourself :)
Pablo Neira Ayuso Sept. 14, 2024, 10:07 p.m. UTC | #3
On Sat, Sep 14, 2024 at 01:19:40PM +0200, Florian Westphal wrote:
> Dan Carpenter <dan.carpenter@linaro.org> wrote:
> > The cgroup_get_from_path() function never returns NULL, it returns error
> > pointers.  Update the error handling to match.
> 
> Good news, I will retire in the next few years so I don't send shit
> patches anymore.
> 
> Acked-by: Florian Westphal <fw@strlen.de>

This is also my fault, I did not help to catch this error in any way:

Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
patchwork-bot+netdevbpf@kernel.org Sept. 15, 2024, 4:01 p.m. UTC | #4
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sat, 14 Sep 2024 12:56:51 +0300 you wrote:
> The cgroup_get_from_path() function never returns NULL, it returns error
> pointers.  Update the error handling to match.
> 
> Fixes: 7f3287db6543 ("netfilter: nft_socket: make cgroupsv2 matching work with namespaces")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  net/netfilter/nft_socket.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Here is the summary with links:
  - [net] netfilter: nft_socket: Fix a NULL vs IS_ERR() bug in nft_socket_cgroup_subtree_level()
    https://git.kernel.org/netdev/net/c/7052622fccb1

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/netfilter/nft_socket.c b/net/netfilter/nft_socket.c
index ac3c9e9cf0f3..f5da0c1775f2 100644
--- a/net/netfilter/nft_socket.c
+++ b/net/netfilter/nft_socket.c
@@ -61,8 +61,8 @@  static noinline int nft_socket_cgroup_subtree_level(void)
 	struct cgroup *cgrp = cgroup_get_from_path("/");
 	int level;
 
-	if (!cgrp)
-		return -ENOENT;
+	if (IS_ERR(cgrp))
+		return PTR_ERR(cgrp);
 
 	level = cgrp->level;