summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-04-18 11:56:00 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-04-19 08:26:51 +0200
commitcb8cf33ce849f71f7fe1d717aa02b5669a54a19e (patch)
tree6d6f9692573033e1b516a896a8fb1333f25d1a37 /drivers/usb
parent24a6b3f8eabf08b589a2860aee9b670fa88cd085 (diff)
downloadbarebox-cb8cf33ce849f71f7fe1d717aa02b5669a54a19e.tar.gz
barebox-cb8cf33ce849f71f7fe1d717aa02b5669a54a19e.tar.xz
fix erasing/protecting flashes with unspecified size
fixes: 81737c1 mtd: Fix erasing of devices >4GiB Several places erased a complete flash partition passing ~0 as count to erase(). With the above commit count to erase was changed from an unsigned type to a signed type, so the (count > f->size - offset) check in erase() no longer triggers and the ~0 count is no longer adjusted to the whole device size. Among other things this results in saveenv failures on NOR flashes. This patch fixes this by introducing an explicit macro for erasing the whole device which is tested for in erase(). All other negative values are rejected. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Giorgio <giorgio.nicole@arcor.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/dfu.c4
-rw-r--r--drivers/usb/gadget/f_fastboot.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c
index 351b584796..d7bf92cdff 100644
--- a/drivers/usb/gadget/dfu.c
+++ b/drivers/usb/gadget/dfu.c
@@ -359,7 +359,7 @@ static int handle_dnload(struct usb_function *f, const struct usb_ctrlrequest *c
ret = -EINVAL;
goto err_out;
}
- ret = erase(fd, ~0, 0);
+ ret = erase(fd, ERASE_SIZE_ALL, 0);
close(fd);
if (ret && ret != -ENOSYS) {
perror("erase");
@@ -479,7 +479,7 @@ static int dfu_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
goto out;
}
- ret = erase(dfufd, ~0, 0);
+ ret = erase(dfufd, ERASE_SIZE_ALL, 0);
if (ret && ret != -ENOSYS) {
dfu->dfu_status = DFU_STATUS_errERASE;
perror("erase");
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 0df08c9a2b..aaf784913b 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -784,7 +784,7 @@ static void cb_erase(struct usb_ep *ep, struct usb_request *req, const char *cmd
if (fd < 0)
fastboot_tx_print(f_fb, "FAIL%s", strerror(-fd));
- ret = erase(fd, ~0, 0);
+ ret = erase(fd, ERASE_SIZE_ALL, 0);
close(fd);