From 08f5a5a3be2e8a9d1df0890d6f1a575a18b744b9 Mon Sep 17 00:00:00 2001 From: Gao Feng Date: Mon, 28 Nov 2022 22:41:41 +0800 Subject: [PATCH] meminfo: buflen identify the left of buffer It is enought to only checking the buflen's avaiable or not. (total size means total copied size) Co-authored-by: Petro Karashchenko --- fs/procfs/fs_procfsmeminfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/procfs/fs_procfsmeminfo.c b/fs/procfs/fs_procfsmeminfo.c index 49d55ea795..fa847657cb 100644 --- a/fs/procfs/fs_procfsmeminfo.c +++ b/fs/procfs/fs_procfsmeminfo.c @@ -302,7 +302,7 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer, for (entry = g_procfs_meminfo; entry != NULL; entry = entry->next) { - if (totalsize < buflen) + if (buflen > 0) { struct mallinfo minfo; @@ -328,7 +328,7 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer, } #ifdef CONFIG_MM_PGALLOC - if (totalsize < buflen) + if (buflen > 0) { struct pginfo_s pginfo; unsigned long total; @@ -359,7 +359,7 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer, #endif #if defined(CONFIG_ARCH_HAVE_PROGMEM) && defined(CONFIG_FS_PROCFS_INCLUDE_PROGMEM) - if (totalsize < buflen) + if (buflen > 0) { struct progmem_info_s progmem;