Wastes less memory and allows using more memory for ecc than data.
Signed-off-by: Arve Hjønnevåg <arve@android.com>
[jstultz: Tweaked commit subject]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
prz->ecc_block_size = 128;
prz->ecc_size = ecc_size;
- ecc_blocks = DIV_ROUND_UP(prz->buffer_size, prz->ecc_block_size);
+ ecc_blocks = DIV_ROUND_UP(prz->buffer_size - prz->ecc_size,
+ prz->ecc_block_size + prz->ecc_size);
ecc_total = (ecc_blocks + 1) * prz->ecc_size;
if (ecc_total >= prz->buffer_size) {
pr_err("%s: invalid ecc_size %u (total %zu, buffer size %zu)\n",