diff options
author | Cyril Bur <cyril.bur@au1.ibm.com> | 2017-08-16 19:35:40 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-08-22 11:59:17 +1000 |
commit | 916bc2d8da8fee71653c325cc752f0ce901a58a2 (patch) | |
tree | 260b5849c4e32d4fea3afe39be1db6821ce76dac /external | |
parent | c8fd6a57254e663143558acada294b8ec6bf8b99 (diff) | |
download | skiboot-916bc2d8da8fee71653c325cc752f0ce901a58a2.zip skiboot-916bc2d8da8fee71653c325cc752f0ce901a58a2.tar.gz skiboot-916bc2d8da8fee71653c325cc752f0ce901a58a2.tar.bz2 |
external/pflash: Fix not checking return values in set_ecc().
When writing ECC bytes to ECC regions we don't check that
blocklevel_write() succeeds nor we check that the region was correctly
erased prior to setting the ECC bytes.
Fixes: CID 163737
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r-- | external/pflash/pflash.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c index ceab3f4..bfc975f 100644 --- a/external/pflash/pflash.c +++ b/external/pflash/pflash.c @@ -372,18 +372,27 @@ static int set_ecc(struct flash_details *flash, uint32_t start, uint32_t size) uint32_t i = start + 8; uint8_t ecc = 0; bool confirm; + int rc; printf("About to erase and set ECC bits in region 0x%08x to 0x%08x\n", start, start + size); confirm = check_confirm(); if (!confirm) return 1; - erase_range(flash, start, size, true, NULL, 0); + rc = erase_range(flash, start, size, true, NULL, 0); + if (rc) { + fprintf(stderr, "Couldn't erase region to mark with ECC\n"); + return rc; + } printf("Programming ECC bits...\n"); progress_init(size); while (i < start + size) { - blocklevel_write(flash->bl, i, &ecc, sizeof(ecc)); + rc = blocklevel_write(flash->bl, i, &ecc, sizeof(ecc)); + if (rc) { + fprintf(stderr, "\nError setting ECC byte at 0x%08x\n", i); + return rc; + } i += 9; progress_tick(i - start); } |