From 56b5ae0640de974aa250b4aeeb3049fc9ea66866 Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Thu, 3 Feb 2022 15:23:52 +0800 Subject: [PATCH] net/tcp/netdev/mld: correct the netlock handling Signed-off-by: chao.an --- net/mld/mld_timer.c | 1 + net/netdev/netdev_register.c | 1 + net/tcp/tcp_conn.c | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/net/mld/mld_timer.c b/net/mld/mld_timer.c index 4470ed86f5..da8f830010 100644 --- a/net/mld/mld_timer.c +++ b/net/mld/mld_timer.c @@ -343,6 +343,7 @@ static void mld_polldog_work(FAR void *arg) fwarn("WARNING: No device associated with ifindex=%d\n", group->ifindex); + net_unlock(); return; } diff --git a/net/netdev/netdev_register.c b/net/netdev/netdev_register.c index c4ade6f611..0aefec673d 100644 --- a/net/netdev/netdev_register.c +++ b/net/netdev/netdev_register.c @@ -375,6 +375,7 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype) ifindex = get_ifindex(); if (ifindex < 0) { + net_unlock(); return ifindex; } diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c index a8161d349c..f2413a1fc2 100644 --- a/net/tcp/tcp_conn.c +++ b/net/tcp/tcp_conn.c @@ -425,6 +425,7 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn, if (port < 0) { nerr("ERROR: tcp_selectport failed: %d\n", port); + net_unlock(); return port; } @@ -448,11 +449,10 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn, conn->lport = 0; net_ipv4addr_copy(conn->u.ipv4.laddr, INADDR_ANY); - return ret; } net_unlock(); - return OK; + return ret; } #endif /* CONFIG_NET_IPv4 */ @@ -492,6 +492,7 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn, if (port < 0) { nerr("ERROR: tcp_selectport failed: %d\n", port); + net_unlock(); return port; } @@ -515,11 +516,10 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn, conn->lport = 0; net_ipv6addr_copy(conn->u.ipv6.laddr, g_ipv6_unspecaddr); - return ret; } net_unlock(); - return OK; + return ret; } #endif /* CONFIG_NET_IPv6 */