diff mbox series

[net-next,v2] l2tp: remove unneeded null check in l2tp_v2_session_get_next

Message ID 20240903113547.1261048-1-jchapman@katalix.com (mailing list archive)
State Accepted
Commit 510c0732fc8cabe7bca8de291c74d3f3cc36df48
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] l2tp: remove unneeded null check in l2tp_v2_session_get_next | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -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 6 of 6 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 No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 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-04--15-00 (tests: 718)

Commit Message

James Chapman Sept. 3, 2024, 11:35 a.m. UTC
Commit aa92c1cec92b ("l2tp: add tunnel/session get_next helpers") uses
idr_get_next APIs to iterate over l2tp session IDR lists.  Sessions in
l2tp_v2_session_idr always have a non-null session->tunnel pointer
since l2tp_session_register sets it before inserting the session into
the IDR. Therefore the null check on session->tunnel in
l2tp_v2_session_get_next is redundant and can be removed. Removing the
check avoids a warning from lkp.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202408111407.HtON8jqa-lkp@intel.com/
CC: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Tom Parkin <tparkin@katalix.com>
---

 v2: improve commit log and use acked-by tag
 v1: https://lore.kernel.org/netdev/20240902142953.926891-1-jchapman@katalix.com/

---
 net/l2tp/l2tp_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman Sept. 3, 2024, 4:35 p.m. UTC | #1
On Tue, Sep 03, 2024 at 12:35:47PM +0100, James Chapman wrote:
> Commit aa92c1cec92b ("l2tp: add tunnel/session get_next helpers") uses
> idr_get_next APIs to iterate over l2tp session IDR lists.  Sessions in
> l2tp_v2_session_idr always have a non-null session->tunnel pointer
> since l2tp_session_register sets it before inserting the session into
> the IDR. Therefore the null check on session->tunnel in
> l2tp_v2_session_get_next is redundant and can be removed. Removing the
> check avoids a warning from lkp.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/r/202408111407.HtON8jqa-lkp@intel.com/
> CC: Dan Carpenter <dan.carpenter@linaro.org>
> Signed-off-by: James Chapman <jchapman@katalix.com>
> Acked-by: Tom Parkin <tparkin@katalix.com>
> ---
> 
>  v2: improve commit log and use acked-by tag
>  v1: https://lore.kernel.org/netdev/20240902142953.926891-1-jchapman@katalix.com/
> 

Thanks for the update.

Reviewed-by: Simon Horman <horms@kernel.org>
patchwork-bot+netdevbpf@kernel.org Sept. 4, 2024, 11:50 p.m. UTC | #2
Hello:

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

On Tue,  3 Sep 2024 12:35:47 +0100 you wrote:
> Commit aa92c1cec92b ("l2tp: add tunnel/session get_next helpers") uses
> idr_get_next APIs to iterate over l2tp session IDR lists.  Sessions in
> l2tp_v2_session_idr always have a non-null session->tunnel pointer
> since l2tp_session_register sets it before inserting the session into
> the IDR. Therefore the null check on session->tunnel in
> l2tp_v2_session_get_next is redundant and can be removed. Removing the
> check avoids a warning from lkp.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] l2tp: remove unneeded null check in l2tp_v2_session_get_next
    https://git.kernel.org/netdev/net-next/c/510c0732fc8c

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index 32102d1ed4cd..3eec23ac5ab1 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -345,7 +345,7 @@  static struct l2tp_session *l2tp_v2_session_get_next(const struct net *net,
 			goto again;
 		}
 
-		if (tunnel && tunnel->tunnel_id == tid &&
+		if (tunnel->tunnel_id == tid &&
 		    refcount_inc_not_zero(&session->ref_count)) {
 			rcu_read_unlock_bh();
 			return session;