[cbootimage PATCH V3 2/7] Add page_size validation when setting page_size value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux