net/can: add write_q free for callback alloc error handling

Release the corresponding resources held when the alloc fails

Signed-off-by: wangjinjing1 <wangjinjing1@xiaomi.com>
This commit is contained in:
wangjinjing1 2025-06-20 12:08:22 +08:00 committed by Xiang Xiao
parent 99584588fc
commit 4fa74e4d18

View file

@ -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;