sched/mqueue: reclaim message upon failure

This reclaims the allocated message if it can't be sent to avoid
memory leaks.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This commit is contained in:
Yanfeng Liu 2024-05-26 12:30:56 +08:00 committed by Alan Carvalho de Assis
parent 4197b5aec8
commit 0fc2e74b04
1 changed files with 6 additions and 0 deletions

View File

@ -268,6 +268,12 @@ file_mq_timedsend_internal(FAR struct file *mq, FAR const char *msg,
out_send_message:
ret = nxmq_do_send(msgq, mqmsg, msg, msglen, prio);
}
else
{
/* free the message as it can't be sent */
nxmq_free_msg(mqmsg);
}
/* Exit here with (1) the scheduler locked, (2) a message allocated, (3) a
* wdog allocated, and (4) interrupts disabled.