diff options
author | Andrew Jeffery <andrew@aj.id.au> | 2019-10-03 15:23:39 +0930 |
---|---|---|
committer | Oliver O'Halloran <oohall@gmail.com> | 2019-10-14 16:27:10 +1100 |
commit | bdbbfcacccdb768db587ef73a2a28cf3dc8ceda9 (patch) | |
tree | e44f1e1abbc133a87ec894f6f3dd01af6471171d | |
parent | 6867bd54c21b023b74e924abd6f4c3f1cd9959c2 (diff) | |
download | skiboot-bdbbfcacccdb768db587ef73a2a28cf3dc8ceda9.zip skiboot-bdbbfcacccdb768db587ef73a2a28cf3dc8ceda9.tar.gz skiboot-bdbbfcacccdb768db587ef73a2a28cf3dc8ceda9.tar.bz2 |
blocklevel: smart_write: Deny writes intersecting ECC protected regions
Other code paths don't handle writes spanning mixed regions, and it's a
headache, so deny it here too.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
-rw-r--r-- | libflash/blocklevel.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libflash/blocklevel.c b/libflash/blocklevel.c index a72bed7..f63fb5d 100644 --- a/libflash/blocklevel.c +++ b/libflash/blocklevel.c @@ -512,6 +512,7 @@ int blocklevel_smart_write(struct blocklevel_device *bl, uint64_t pos, const voi uint64_t ecc_start; void *erase_buf; int rc = 0; + int ecc_protection; if (!buf || !bl) { errno = EINVAL; @@ -529,7 +530,14 @@ int blocklevel_smart_write(struct blocklevel_device *bl, uint64_t pos, const voi if (rc) return rc; - if (ecc_protected(bl, pos, len, &ecc_start)) { + ecc_protection = ecc_protected(bl, pos, len, &ecc_start); + if (ecc_protection == -1) { + FL_ERR("%s: Can't cope with partial ecc\n", __func__); + errno = EINVAL; + return FLASH_ERR_PARM_ERROR; + } + + if (ecc_protection) { FL_DBG("%s: region has ECC\n", __func__); len = ecc_buffer_size(len); |