summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPenny Chiu <pchiu@nvidia.com>2014-04-11 17:50:38 +0800
committerStephen Warren <swarren@nvidia.com>2014-04-15 12:02:05 -0600
commitee24d10641faa87124094621ba2d5583123c47a9 (patch)
tree2e67846bddf648f927171b2a092587c3cbf1b199
parent3d0bff52c4e85ff0571bea8e0050dbb3ca2a2ef0 (diff)
downloadnvidia-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.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/set.c b/src/set.c
index 08c9fb6..b2872a6 100644
--- a/src/set.c
+++ b/src/set.c
@@ -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);