Skip to content

Commit

Permalink
mm/iob: Don't return NULL in iob_pack
Browse files Browse the repository at this point in the history
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 <wengzhe@xiaomi.com>
  • Loading branch information
wengzhe committed Apr 22, 2023
1 parent ad6aef5 commit 1961409
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions mm/iob/iob_pack.c
Expand Up @@ -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) */
Expand Down

0 comments on commit 1961409

Please sign in to comment.