diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2016-04-18 11:56:00 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-04-19 08:26:51 +0200 |
commit | cb8cf33ce849f71f7fe1d717aa02b5669a54a19e (patch) | |
tree | 6d6f9692573033e1b516a896a8fb1333f25d1a37 /arch/arm/mach-omap | |
parent | 24a6b3f8eabf08b589a2860aee9b670fa88cd085 (diff) | |
download | barebox-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 'arch/arm/mach-omap')
-rw-r--r-- | arch/arm/mach-omap/am33xx_bbu_nand.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap/am33xx_bbu_spi_mlo.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/arch/arm/mach-omap/am33xx_bbu_nand.c b/arch/arm/mach-omap/am33xx_bbu_nand.c index ee767d32e4..25f0e79ee6 100644 --- a/arch/arm/mach-omap/am33xx_bbu_nand.c +++ b/arch/arm/mach-omap/am33xx_bbu_nand.c @@ -40,7 +40,7 @@ static int write_image(const char *devfile, const void *image, size_t size) return fd; } - ret = erase(fd, ~0, 0); + ret = erase(fd, ERASE_SIZE_ALL, 0); if (ret < 0) { pr_err("could not erase %s: %s\n", devfile, errno_str()); diff --git a/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c b/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c index 702bb9af59..69a73ffb06 100644 --- a/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c +++ b/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c @@ -70,7 +70,7 @@ static int spi_nor_mlo_handler(struct bbu_handler *handler, goto out; } - ret = erase(dstfd, ~0, 0); + ret = erase(dstfd, ERASE_SIZE_ALL, 0); if (ret < 0) { printf("could not erase %s: %s", data->devicefile, errno_str()); goto out1; |