net: Return errno in sk->sk_prot->get_port().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Fri, 18 Nov 2022 18:25:06 +0000 (10:25 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:13 +0000 (13:32 +0100)
commitd24fd986ae9d40fe3fcea0c1d7c44605b3527ca4
tree114cb35a9e2a103267b834b14096118451ec25be
parent073b50de84cbc9064180097d89facecdbb49e177
net: Return errno in sk->sk_prot->get_port().

[ Upstream commit 7a7160edf1bfde25422262fb26851cef65f695d3 ]

We assume the correct errno is -EADDRINUSE when sk->sk_prot->get_port()
fails, so some ->get_port() functions return just 1 on failure and the
callers return -EADDRINUSE instead.

However, mptcp_get_port() can return -EINVAL.  Let's not ignore the error.

Note the only exception is inet_autobind(), all of whose callers return
-EAGAIN instead.

Fixes: cec37a6e41aa ("mptcp: Handle MP_CAPABLE options for outgoing connections")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/af_inet.c
net/ipv4/inet_connection_sock.c
net/ipv4/ping.c
net/ipv4/udp.c
net/ipv6/af_inet6.c