Skip to contentSkip to conversation

l2tp: remove unneeded null check in l2tp_v2_session_get_next

PATCH Applied James Chapman 3 participants 3 messages Sep 3, 2024 – Sep 4, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 l2tp: remove unneeded null check in l2tp_v2_session_get_next

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.

---

v2: improve commit log and use acked-by tag
v1: https://lore.kernel.org/netdev/[email protected]/

---
 net/l2tp/l2tp_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/l2tp/l2tp_core.c +1 -1
index 32102d1ed4cd..3eec23ac5ab1 100644
@@ -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;
Signature · 1 line
2.34.1
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 13 lines · James Chapman

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.

Quoted 5 lines

---

v2: improve commit log and use acked-by tag
v1: https://lore.kernel.org/netdev/[email protected]/

Thanks for the update.

#2 lore raw
In reply to James Chapman
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · 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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html