summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-02-02 14:02:32 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-02-09 10:24:14 +0100
commit41185879b2d620987dec99e77d004c3b2cc39ac3 (patch)
treeca080e023c8691bdf887588940b61b50d02682e5 /drivers
parent09788a0b9d2b9a56cb444db1149072005e8a82c3 (diff)
downloadbarebox-41185879b2d620987dec99e77d004c3b2cc39ac3.tar.gz
barebox-41185879b2d620987dec99e77d004c3b2cc39ac3.tar.xz
usb: gadget: fastboot: Always remove temporary file
We should consistently remove the temporary image file, regardless of the error code. To do so, always jump to the end of the function where the temporary file is removed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/gadget/f_fastboot.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 62b13bcb8c..db9b906b2b 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -895,7 +895,8 @@ static void cb_flash(struct f_fastboot *f_fb, const char *cmd)
if (!fentry) {
fastboot_tx_print(f_fb, "FAILNo such partition: %s", cmd);
- return;
+ ret = -ENOENT;
+ goto out;
}
filename = fentry->filename;
@@ -903,22 +904,21 @@ static void cb_flash(struct f_fastboot *f_fb, const char *cmd)
if (filetype == filetype_android_sparse) {
if (!IS_ENABLED(USB_GADGET_FASTBOOT_SPARSE)) {
fastboot_tx_print(f_fb, "FAILsparse image not supported");
- return;
+ ret = -EOPNOTSUPP;
+ goto out;
}
ret = fastboot_handle_sparse(f_fb, fentry);
- if (ret) {
+ if (ret)
fastboot_tx_print(f_fb, "FAILwriting sparse image: %s",
strerror(-ret));
- return;
- }
goto out;
}
ret = check_ubi(f_fb, fentry, filetype);
if (ret < 0)
- return;
+ goto out;
if (ret > 0) {
struct mtd_info *mtd;
@@ -926,11 +926,8 @@ static void cb_flash(struct f_fastboot *f_fb, const char *cmd)
mtd = get_mtd(f_fb, fentry->filename);
ret = do_ubiformat(f_fb, mtd, FASTBOOT_TMPFILE);
- if (ret) {
+ if (ret)
fastboot_tx_print(f_fb, "FAILwrite partition: %s", strerror(-ret));
- return;
- }
-
goto out;
}
@@ -951,7 +948,7 @@ static void cb_flash(struct f_fastboot *f_fb, const char *cmd)
f_fb->download_size);
if (ret) {
fastboot_tx_print(f_fb, "FAILreading barebox");
- return;
+ goto out;
}
data.image = image;
@@ -960,10 +957,8 @@ static void cb_flash(struct f_fastboot *f_fb, const char *cmd)
free(image);
- if (ret) {
+ if (ret)
fastboot_tx_print(f_fb, "FAILupdate barebox: %s", strerror(-ret));
- return;
- }
goto out;
}
@@ -971,15 +966,14 @@ static void cb_flash(struct f_fastboot *f_fb, const char *cmd)
copy:
ret = copy_file(FASTBOOT_TMPFILE, filename, 1);
- unlink(FASTBOOT_TMPFILE);
-
- if (ret) {
+ if (ret)
fastboot_tx_print(f_fb, "FAILwrite partition: %s", strerror(-ret));
- return;
- }
out:
- fastboot_tx_print(f_fb, "OKAY");
+ if (!ret)
+ fastboot_tx_print(f_fb, "OKAY");
+
+ unlink(FASTBOOT_TMPFILE);
}
static void cb_erase(struct f_fastboot *f_fb, const char *cmd)