From 78c11c31e8ccd9650b176dcec27b4809bf59c43a Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Tue, 23 Jul 2024 10:04:27 +0800 Subject: [PATCH] system/fastboot: Fix fd leak of fastboot_filedump_upload() Signed-off-by: wangjianyu3 --- 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; }