You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2022/02/03 14:09:25 UTC

[incubator-nuttx] 01/03: net/tcp/netdev/mld: correct the netlock handling

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 56b5ae0640de974aa250b4aeeb3049fc9ea66866
Author: chao.an <an...@xiaomi.com>
AuthorDate: Thu Feb 3 15:23:52 2022 +0800

    net/tcp/netdev/mld: correct the netlock handling
    
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 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 4470ed8..da8f830 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 c4ade6f..0aefec6 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 a8161d3..f2413a1 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 */