[PATCH 13/20] fastboot: Warn when cb_download is called with file still open
Sascha Hauer
s.hauer at pengutronix.de
Thu Aug 13 09:42:50 EDT 2020
Warn when we are about to open a new download file without having
closed the old one.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
common/fastboot.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/common/fastboot.c b/common/fastboot.c
index c800e89a65..7f5b8b6f03 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -337,6 +337,7 @@ int fastboot_handle_download_data(struct fastboot *fb, const void *buffer,
void fastboot_download_finished(struct fastboot *fb)
{
close(fb->download_fd);
+ fb->download_fd = 0;
printf("\n");
@@ -356,6 +357,11 @@ static void cb_download(struct fastboot *fb, const char *cmd)
init_progression_bar(fb->download_size);
+ if (fb->download_fd > 0) {
+ pr_err("%s called and %s is still opened\n", __func__, fb->tempname);
+ close(fb->download_fd);
+ }
+
fb->download_fd = open(fb->tempname, O_WRONLY | O_CREAT | O_TRUNC);
if (fb->download_fd < 0) {
fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, "internal error");
--
2.28.0
More information about the barebox
mailing list