diff options
author | Penny Chiu <pchiu@nvidia.com> | 2014-04-11 17:50:38 +0800 |
---|---|---|
committer | Stephen Warren <swarren@nvidia.com> | 2014-04-15 12:02:05 -0600 |
commit | ee24d10641faa87124094621ba2d5583123c47a9 (patch) | |
tree | 2e67846bddf648f927171b2a092587c3cbf1b199 | |
parent | 3d0bff52c4e85ff0571bea8e0050dbb3ca2a2ef0 (diff) | |
download | nvidia-cbootimage-ee24d10641faa87124094621ba2d5583123c47a9.tar.gz |
Add page_size validation when setting page_size value
The valid page_size value should be a power of two, so add this
check when setting page_size value.
Signed-off-by: Penny Chiu <pchiu@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
-rw-r--r-- | src/set.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -169,6 +169,11 @@ int context_set_value(build_image_context *context, case token_page_size: context->page_size = value; context->page_size_log2 = log2(value); + + if (value != (u_int32_t)(1 << context->page_size_log2)) { + printf("Error: Page size must be a power of 2.\n"); + return 1; + } context->pages_per_blk= 1 << (context->block_size_log2- context->page_size_log2); |