This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 78c11c31e8ccd9650b176dcec27b4809bf59c43a
Author: wangjianyu3 <[email protected]>
AuthorDate: Tue Jul 23 10:04:27 2024 +0800

    system/fastboot: Fix fd leak of fastboot_filedump_upload()
    
    Signed-off-by: wangjianyu3 <[email protected]>
---
 system/fastboot/fastboot.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/system/fastboot/fastboot.c b/system/fastboot/fastboot.c
index 6606d306c..0f9336d78 100644
--- a/system/fastboot/fastboot.c
+++ b/system/fastboot/fastboot.c
@@ -673,6 +673,7 @@ static int fastboot_filedump_upload(FAR struct 
fastboot_ctx_s *context)
     {
       fb_err("Invalid argument, offset: %" PRIdOFF "\n",
              context->upload_param.u.file.offset);
+      close(fd);
       return -errno;
     }
 
@@ -690,12 +691,14 @@ static int fastboot_filedump_upload(FAR struct 
fastboot_ctx_s *context)
                               nread) < 0)
         {
           fb_err("Upload failed (%zu bytes left)\n", size);
+          close(fd);
           return -errno;
         }
 
       size -= nread;
     }
 
+  close(fd);
   return 0;
 }
 

Reply via email to