This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 44a04733d4edc43d3208d3b0a712578923efc18a
Author: Zhe Weng <[email protected]>
AuthorDate: Thu Apr 20 12:05:17 2023 +0800

    mm/iob: Don't return NULL in iob_pack
    
    We don't want to get a NULL pointer after iob_pack on an IOB chain with
    several iobs with length 0, it should return one IOB with length 0.
    Otherwise each place calls iob_pack needs to check the result.
    
    Signed-off-by: Zhe Weng <[email protected]>
---
 mm/iob/iob_pack.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/mm/iob/iob_pack.c b/mm/iob/iob_pack.c
index bc0fbb96fb..55b590311f 100644
--- a/mm/iob/iob_pack.c
+++ b/mm/iob/iob_pack.c
@@ -51,15 +51,11 @@ FAR struct iob_s *iob_pack(FAR struct iob_s *iob)
   unsigned int ncopy;
   unsigned int navail;
 
-  /* Handle special cases */
+  /* Handle special cases, preserve at least one iob. */
 
-  while (iob->io_len <= 0)
+  while (iob->io_len <= 0 && iob->io_flink != NULL)
     {
       iob = iob_free(iob);
-      if (iob == NULL)
-        {
-          return NULL;
-        }
     }
 
   /* Now remember the head of the chain (for the return value) */

Reply via email to