From 44a04733d4edc43d3208d3b0a712578923efc18a Mon Sep 17 00:00:00 2001 From: Zhe Weng Date: Thu, 20 Apr 2023 12:05:17 +0800 Subject: [PATCH] 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 --- 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 bc0fbb96fbf..55b590311f3 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) */