summaryrefslogtreecommitdiff
path: root/net/ipv6
diff options
context:
space:
mode:
authorYueHaibing <yuehaibing@huawei.com>2018-12-19 14:45:09 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-20 10:13:10 +0100
commitf74e04acc2d76ae90ae46adf524d7baf9c1a243c (patch)
treecd9ca017e1764f4a5040f1a3b4aace29c87883e8 /net/ipv6
parentb489ed3fbc3b894a1fe82d16d7570eeba2a9a799 (diff)
xfrm6_tunnel: Fix spi check in __xfrm6_tunnel_alloc_spi
[ Upstream commit fa89a4593b927b3f59c3b69379f31d3b22272e4e ] gcc warn this: net/ipv6/xfrm6_tunnel.c:143 __xfrm6_tunnel_alloc_spi() warn: always true condition '(spi <= 4294967295) => (0-u32max <= u32max)' 'spi' is u32, which always not greater than XFRM6_TUNNEL_SPI_MAX because of wrap around. So the second forloop will never reach. Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/xfrm6_tunnel.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index 5743044cd660..56b72cada346 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -144,6 +144,9 @@ static u32 __xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr)
index = __xfrm6_tunnel_spi_check(net, spi);
if (index >= 0)
goto alloc_spi;
+
+ if (spi == XFRM6_TUNNEL_SPI_MAX)
+ break;
}
for (spi = XFRM6_TUNNEL_SPI_MIN; spi < xfrm6_tn->spi; spi++) {
index = __xfrm6_tunnel_spi_check(net, spi);