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

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


The following commit(s) were added to refs/heads/master by this push:
     new faa4d7ff8dd net/udp: fix conn_unlock not called outside conditional 
block
faa4d7ff8dd is described below

commit faa4d7ff8dd15fe4f6c9932e4dd8485a5e8ca2ab
Author: zhanghongyu <[email protected]>
AuthorDate: Wed Apr 8 21:26:07 2026 +0800

    net/udp: fix conn_unlock not called outside conditional block
    
    Move conn_unlock() call outside the if block in psock_udp_sendto()
    to ensure the connection lock is always released before returning,
    preventing a potential deadlock when the condition is not met.
    
    Signed-off-by: zhanghongyu <[email protected]>
---
 net/udp/udp_sendto_buffered.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/udp/udp_sendto_buffered.c b/net/udp/udp_sendto_buffered.c
index f4f8e031907..be4785d0e80 100644
--- a/net/udp/udp_sendto_buffered.c
+++ b/net/udp/udp_sendto_buffered.c
@@ -895,10 +895,10 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR 
const void *buf,
           conn_unlock(&conn->sconn);
           goto errout_with_wrb;
         }
-
-      conn_unlock(&conn->sconn);
     }
 
+  conn_unlock(&conn->sconn);
+
   /* Return the number of bytes that will be sent */
 
   return len;

Reply via email to