From 66d854371baaf67b06fdd8cd1175baba4db8ec2e Mon Sep 17 00:00:00 2001 From: Jiuzhu Dong Date: Fri, 18 Feb 2022 20:28:04 +0800 Subject: [PATCH] fs/files_allocate: assert when fd overflow Signed-off-by: Jiuzhu Dong --- fs/inode/fs_files.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c index 50ec037b78..ba310176f4 100644 --- a/fs/inode/fs_files.c +++ b/fs/inode/fs_files.c @@ -98,6 +98,12 @@ static int files_extend(FAR struct filelist *list, size_t row) list->fl_files = tmp; list->fl_rows = row; + + /* Note: If assertion occurs, the fl_rows has a overflow. + * And there may be file descriptors leak in system. + */ + + DEBUGASSERT(list->fl_rows == row); return 0; }