osal/rtx4: size the queue pool in bytes and fail send when it is exhausted (#4129)
diff --git a/src/osal/osal_rtx4.h b/src/osal/osal_rtx4.h
index 32200c5..5d4e3e0 100644
--- a/src/osal/osal_rtx4.h
+++ b/src/osal/osal_rtx4.h
@@ -100,6 +100,7 @@
 }
 
 TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) {
+  (void) sem_hdl;
   // TODO: implement
 }
 
@@ -148,7 +149,10 @@
 
 TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) {
   os_mbx_init(qdef->mbox, (qdef->depth + 4) * 4);
-  _init_box(qdef->pool, ((qdef->item_sz+3)/4)*(qdef->depth) + 3, qdef->item_sz);
+  uint32_t const pool_size = (((qdef->item_sz + 3u) / 4u) * qdef->depth + 3u) * sizeof(U32);
+  if (_init_box(qdef->pool, pool_size, qdef->item_sz) != 0) {
+    return NULL;
+  }
   return qdef;
 }
 
@@ -168,7 +172,11 @@
 }
 
 TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) {
+  // Each message owns a pool block, so allocation reserves mailbox capacity.
   void* buf = _alloc_box(qhdl->pool);
+  if (buf == NULL) {
+    return false;
+  }
   memcpy(buf, data, qhdl->item_sz);
   if ( !in_isr ) {
     os_mbx_send(qhdl->mbox, buf, 0xFFFF);