diff options
author | Aaron Lu <aaron.lu@intel.com> | 2017-04-18 16:17:32 +0800 |
---|---|---|
committer | Fengguang Wu <fengguang.wu@intel.com> | 2017-04-18 16:17:32 +0800 |
commit | 81cfae6d3da6f91d829369454d34fbe6b7b608f6 (patch) | |
tree | e8d7a6106c108ee581bdda1eb77228a305ffbecc | |
parent | fe0353b13482d879c48d3841d15457a0fd5eca2c (diff) | |
download | vm-scalability-81cfae6d3da6f91d829369454d34fbe6b7b608f6.tar.gz |
usemem_remap: use unsigned long for pagesize
There are several places for pagesize doing arithmetic operations and
due to its int type, the result could overflow and yielding strange
result like end is calculated with a smaller value than start, etc.
The subsequent file_remap_pages will then fail with -EINVAL.
I also changed the type of no_of_pages from int to unsigned long for
similar reasons(although it's not required for this fix).
https://jira01.devtools.intel.com/browse/OLT-1605
Reported-by: Philip Li <philip.li@intel.com>
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
-rw-r--r-- | usemem_remap.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/usemem_remap.c b/usemem_remap.c index 1dfe087..737624b 100644 --- a/usemem_remap.c +++ b/usemem_remap.c @@ -18,11 +18,11 @@ int main (int argc, char *argv[]) { int fd; - int pagesize = getpagesize(); + unsigned long pagesize = getpagesize(); int i; unsigned long size; - int no_of_pages; + unsigned long no_of_pages; /* initialize to NULL */ unsigned char *start = NULL; |