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

commit 4fa74e4d18b27d9c2e3dbcb6d5c11532e22aced0
Author: wangjinjing1 <[email protected]>
AuthorDate: Fri Jun 20 12:08:22 2025 +0800

    net/can: add write_q free for callback alloc error handling
    
    Release the corresponding resources held when the alloc fails
    
    Signed-off-by: wangjinjing1 <[email protected]>
---
 net/can/can_sendmsg_buffered.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/can/can_sendmsg_buffered.c b/net/can/can_sendmsg_buffered.c
index 0d45aea9b3c..22078182646 100644
--- a/net/can/can_sendmsg_buffered.c
+++ b/net/can/can_sendmsg_buffered.c
@@ -378,7 +378,7 @@ ssize_t can_sendmsg(FAR struct socket *psock, FAR struct 
msghdr *msg,
 
           nerr("ERROR: Failed to allocate callback\n");
           ret = -ENOMEM;
-          goto errout_with_wrb;
+          goto errout_with_wq;
         }
 
       /* Set up the callback in the connection */
@@ -407,6 +407,9 @@ ssize_t can_sendmsg(FAR struct socket *psock, FAR struct 
msghdr *msg,
 errout_with_wrb:
   iob_free_chain(wb_iob);
 
+errout_with_wq:
+  iob_free_queue(&conn->write_q);
+
 errout_with_lock:
   net_unlock();
   return ret;

Reply via email to