inet: Don't go into port scan when looking for specific bind port
commit9af7e923fdd82dc25ad5ea75e24e92708947f961
authorTom Herbert <tom@herbertland.com>
Thu, 15 Dec 2016 00:54:15 +0000 (14 16:54 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 17 Dec 2016 16:13:19 +0000 (17 11:13 -0500)
tree8422da81ea838c2fb4dd8aa50ad22a0797115c9e
parent0eb6984f70005e792917d9e51142a57f79b32c91
inet: Don't go into port scan when looking for specific bind port

inet_csk_get_port is called with port number (snum argument) that may be
zero or nonzero. If it is zero, then the intent is to find an available
ephemeral port number to bind to. If snum is non-zero then the caller
is asking to allocate a specific port number. In the latter case we
never want to perform the scan in ephemeral port range. It is
conceivable that this can happen if the "goto again" in "tb_found:"
is done. This patch adds a check that snum is zero before doing
the "goto again".

Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/inet_connection_sock.c