aboutsummaryrefslogtreecommitdiff
path: root/net/ipv4/udp.c
diff options
context:
space:
mode:
authorKuniyuki Iwashima2022-11-18 10:25:06 -0800
committerGreg Kroah-Hartman2022-12-31 13:32:13 +0100
commitd24fd986ae9d40fe3fcea0c1d7c44605b3527ca4 (patch)
tree114cb35a9e2a103267b834b14096118451ec25be /net/ipv4/udp.c
parent073b50de84cbc9064180097d89facecdbb49e177 (diff)
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>
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r--net/ipv4/udp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 83fdd2b8afd6..2eaf47e23b22 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -235,7 +235,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
struct udp_table *udptable = sk->sk_prot->h.udp_table;
struct udp_hslot *hslot, *hslot2;
struct net *net = sock_net(sk);
- int error = 1;
+ int error = -EADDRINUSE;
if (!snum) {
DECLARE_BITMAP(bitmap, PORTS_PER_CHAIN);