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 <[email protected]>
---
 src/set.c | 5 +++++
 1 file changed, 5 insertions(+)

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);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to