net/udp: fix net_[un]lock() in udp_bind

net_unlock() called without a previous call to net_lock().

Error introduced by b10d6be17a
This commit is contained in:
Kian Karas 2024-02-08 14:32:20 +01:00 committed by Alan Carvalho de Assis
parent 80da796897
commit 324446bbba

View file

@ -816,6 +816,10 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr)
}
#endif
/* Interrupts must be disabled while access the UDP connection list */
net_lock();
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (conn->domain == PF_INET)
@ -928,10 +932,6 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr)
}
else
{
/* Interrupts must be disabled while access the UDP connection list */
net_lock();
/* Is any other UDP connection already bound to this address
* and port ?
*/
@ -958,10 +958,9 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr)
{
ret = -EADDRINUSE;
}
net_unlock();
}
net_unlock();
return ret;
}