This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 5d05ca39fbf0bcd9f63d537869843aa714fff5ff Author: zhaohaiyang1 <[email protected]> AuthorDate: Mon Jul 27 15:15:17 2026 +0800 mm/iob: add null check for iob2 in iob_clone_partial. In iob_clone_partial(), the destination skip loop (while iob2 != NULL) may exhaust the iob chain causing iob2 to become NULL via IOB_LINK_GET(). The subsequent pack loop at line 185 dereferences iob2->io_data without verifying iob2 is non-NULL, triggering Coverity CID 3879616 (Dereference after null check). Add a defensive null check for iob2 at the top of the pack loop body. If iob2 is NULL (destination chain exhausted), return -ENOMEM to avoid null pointer dereference. Coverity CID: 3879616 Checker: FORWARD_NULL (Dereference after null check) File: mm/iob/iob_clone.c Signed-off-by: zhaohaiyang1 <[email protected]> --- mm/iob/iob_clone.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/iob/iob_clone.c b/mm/iob/iob_clone.c index 2a465b03bfb..0a726f6ddff 100644 --- a/mm/iob/iob_clone.c +++ b/mm/iob/iob_clone.c @@ -193,6 +193,11 @@ int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len, * copy to that address. */ + if (iob2 == NULL) + { + return -ENOMEM; + } + dest = &iob2->io_data[iob2->io_offset + offset2]; avail2 = IOB_BUFSIZE(iob2) - iob2->io_offset - offset2;
