anchao commented on code in PR #7616:
URL: https://github.com/apache/nuttx/pull/7616#discussion_r1037777578


##########
net/devif/devif_pktsend.c:
##########
@@ -83,16 +55,25 @@
 void devif_pkt_send(FAR struct net_driver_s *dev, FAR const void *buf,
                     unsigned int len)
 {
-  DEBUGASSERT(dev && len > 0 && len < NETDEV_PKTSIZE(dev));
+  unsigned int limit = NETDEV_PKTSIZE(dev) -
+                       CONFIG_NET_LL_GUARDSIZE;
 
-  /* Copy the data into the device packet buffer */
+  if (dev == NULL || len == 0 || len > limit)
+    {
+      nerr("ERROR: devif_pkt_send fail: %p, sndlen: %u, pktlen: %u\n",
+            dev, len, limit);

Review Comment:
   Done



##########
net/devif/devif_pktsend.c:
##########
@@ -83,16 +55,25 @@
 void devif_pkt_send(FAR struct net_driver_s *dev, FAR const void *buf,
                     unsigned int len)
 {
-  DEBUGASSERT(dev && len > 0 && len < NETDEV_PKTSIZE(dev));
+  unsigned int limit = NETDEV_PKTSIZE(dev) -
+                       CONFIG_NET_LL_GUARDSIZE;
 
-  /* Copy the data into the device packet buffer */
+  if (dev == NULL || len == 0 || len > limit)
+    {
+      nerr("ERROR: devif_pkt_send fail: %p, sndlen: %u, pktlen: %u\n",
+            dev, len, limit);
+      return;
+    }
 
-  memcpy(dev->d_buf, buf, len);
+  iob_update_pktlen(dev->d_iob, 0);
 
-  /* Set the number of bytes to send */
+  /* Copy the data into the device packet buffer and set the number of
+   * bytes to send
+   */
 
-  dev->d_len    = len;
-  dev->d_sndlen = len;
+  dev->d_sndlen = (iob_copyin(dev->d_iob, buf, len, 0, false) == len) ?

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