提交 422ca860 编写于 作者: A Arve Hjønnevåg 提交者: Anton Vorontsov

pstore/ram: Include ecc_size when calculating ecc_block

Wastes less memory and allows using more memory for ecc than data.
Signed-off-by: NArve Hjønnevåg <arve@android.com>
[jstultz: Tweaked commit subject]
Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
Acked-by: NKees Cook <keescook@chromium.org>
Signed-off-by: NAnton Vorontsov <anton@enomsg.org>
上级 c5302672
......@@ -187,7 +187,8 @@ static int persistent_ram_init_ecc(struct persistent_ram_zone *prz,
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",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册