From aefd3ffce6ed8f586290c0044446024f6e6fdcd5 Mon Sep 17 00:00:00 2001 From: Suraj Jitindar Singh Date: Wed, 13 Sep 2017 16:59:46 +1000 Subject: pflash: Fix erase command for unaligned start address The erase_range() function handles erasing the flash for a given start address and length, and can handle an unaligned start address and length. However in the unaligned start address case we are incorrectly calculating the remaining size which can lead to incomplete erases. If we're going to update the remaining size based on what the start address was then we probably want to do that before we overide the origin start address. So rearrange the code so that this is indeed the case. Reported-by: Pridhiviraj Paidipeddi Signed-off-by: Suraj Jitindar Singh Reviewed-by: Cyril Bur Signed-off-by: Stewart Smith --- external/pflash/pflash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'external') diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c index bfc975fe..5b1be3ce 100644 --- a/external/pflash/pflash.c +++ b/external/pflash/pflash.c @@ -331,9 +331,9 @@ static int erase_range(struct flash_details *flash, fprintf(stderr, "Failed to blocklevel_smart_erase(): %d\n", rc); return 1; } - start += flash->erase_granule - (start & erase_mask); size -= flash->erase_granule - (start & erase_mask); done = flash->erase_granule - (start & erase_mask); + start += flash->erase_granule - (start & erase_mask); } progress_tick(done); while (size & ~(erase_mask)) { -- cgit v1.2.1