diff options
author | Andrew Jeffery <andrew@aj.id.au> | 2019-10-03 15:23:39 +0930 |
---|---|---|
committer | Vasant Hegde <hegdevasant@linux.vnet.ibm.com> | 2019-10-23 16:23:29 +0530 |
commit | e81fa10a16b16aba4d1c600131e5d52a4d97a87c (patch) | |
tree | e37b8d62c978e0a5ecb7dc1af229592506449c92 /libflash | |
parent | 0a8f204c9d42d47177c23dd9f8fcd45113b601fc (diff) | |
download | skiboot-e81fa10a16b16aba4d1c600131e5d52a4d97a87c.zip skiboot-e81fa10a16b16aba4d1c600131e5d52a4d97a87c.tar.gz skiboot-e81fa10a16b16aba4d1c600131e5d52a4d97a87c.tar.bz2 |
blocklevel: smart_write: Deny writes intersecting ECC protected regions
[ Upstream commit bdbbfcacccdb768db587ef73a2a28cf3dc8ceda9 ]
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>
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Diffstat (limited to 'libflash')
-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); |