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/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 0fc2e74b04 sched/mqueue: reclaim message upon failure
0fc2e74b04 is described below
commit 0fc2e74b04707f0a6c3e0dc3884238f40b52f342
Author: Yanfeng Liu <[email protected]>
AuthorDate: Sun May 26 12:30:56 2024 +0800
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 <[email protected]>
---
sched/mqueue/mq_timedsend.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sched/mqueue/mq_timedsend.c b/sched/mqueue/mq_timedsend.c
index 58bdaff04c..abe0ab4705 100644
--- a/sched/mqueue/mq_timedsend.c
+++ b/sched/mqueue/mq_timedsend.c
@@ -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.