fjpanag commented on code in PR #7525:
URL: https://github.com/apache/nuttx/pull/7525#discussion_r1111041449


##########
net/ieee802154/ieee802154_conn.c:
##########
@@ -107,20 +107,31 @@ void ieee802154_conn_initialize(void)
 FAR struct ieee802154_conn_s *ieee802154_conn_alloc(void)
 {
   FAR struct ieee802154_conn_s *conn;
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_IEEE802154_ALLOC_CONNS > 0
   int i;
 #endif
 
   /* The free list is protected by the network lock. */
 
   net_lock();
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_IEEE802154_ALLOC_CONNS > 0
   if (dq_peek(&g_free_ieee802154_connections) == NULL)
     {
-      conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_IEEE802154_NCONNS);
+#if CONFIG_NET_IEEE802154_MAX_CONNS > 0
+      if (dq_count(&g_active_ieee802154_connections) +
+          CONFIG_NET_IEEE802154_ALLOC_CONNS
+          >= CONFIG_NET_IEEE802154_MAX_CONNS)
+        {
+          net_unlock();
+          return NULL;
+        }
+#endif
+
+      conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_IEEE802154_ALLOC_CONNS);
+

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to