# \[PATCH AUTOSEL 5.10 04/20\] net: xfrm: Fix end of loop tests for list\_for\_each\_entry

- Subsystems: NETWORKING \[GENERAL\], NETWORKING \[IPSEC\], THE REST
- Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn, Steffen Klassert, Herbert Xu, Linus Torvalds
- List: netdev
- 1 message, 1 author
- Page: https://ratatoskr.run/netdev/2021/08/1473216/t

## \[PATCH AUTOSEL 5.10 04/20\] net: xfrm: Fix end of loop tests for list\_for\_each\_entry

- From: Sasha Levin \<sashal@kernel.org\>
- Date: 2021-08-10 14:17:26 
- Message: https://ratatoskr.run/netdev/2021/08/1473216.md

```text
From: Harshvardhan Jha <redacted>

[ Upstream commit 480e93e12aa04d857f7cc2e6fcec181c0d690404 ]

The list_for_each_entry() iterator, "pos" in this code, can never be
NULL so the warning will never be printed.

Signed-off-by: Harshvardhan Jha <redacted>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/xfrm/xfrm_ipcomp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index 4d422447aadc..0814320472f1 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -250,7 +250,7 @@ static void ipcomp_free_tfms(struct crypto_comp * __percpu *tfms)
 			break;
 	}
 
-	WARN_ON(!pos);
+	WARN_ON(list_entry_is_head(pos, &ipcomp_tfms_list, list));
 
 	if (--pos->users)
 		return;
-- 
2.30.2

```
