[Skiboot] [SKIBOOT] [PATCH] pflash: Fix erase command for unaligned start address

Suraj Jitindar Singh sjitindarsingh at gmail.com
Wed Sep 13 16:59:46 AEST 2017


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 <ppaidipe at in.ibm.com>
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh at gmail.com>
---
 external/pflash/pflash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index bfc975f..5b1be3c 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)) {
-- 
2.9.4



More information about the Skiboot mailing list