diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/resource.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/kernel/resource.c b/kernel/resource.c index 03c897f7935e..8f0e3d0f4bff 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
@@ -274,7 +274,7 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, | |||
274 | void *arg, int (*func)(unsigned long, unsigned long, void *)) | 274 | void *arg, int (*func)(unsigned long, unsigned long, void *)) |
275 | { | 275 | { |
276 | struct resource res; | 276 | struct resource res; |
277 | unsigned long pfn, len; | 277 | unsigned long pfn, end_pfn; |
278 | u64 orig_end; | 278 | u64 orig_end; |
279 | int ret = -1; | 279 | int ret = -1; |
280 | 280 | ||
@@ -284,9 +284,10 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, | |||
284 | orig_end = res.end; | 284 | orig_end = res.end; |
285 | while ((res.start < res.end) && | 285 | while ((res.start < res.end) && |
286 | (find_next_system_ram(&res, "System RAM") >= 0)) { | 286 | (find_next_system_ram(&res, "System RAM") >= 0)) { |
287 | pfn = (unsigned long)(res.start >> PAGE_SHIFT); | 287 | pfn = (res.start + PAGE_SIZE - 1) >> PAGE_SHIFT; |
288 | len = (unsigned long)((res.end + 1 - res.start) >> PAGE_SHIFT); | 288 | end_pfn = (res.end + 1) >> PAGE_SHIFT; |
289 | ret = (*func)(pfn, len, arg); | 289 | if (end_pfn > pfn) |
290 | ret = (*func)(pfn, end_pfn - pfn, arg); | ||
290 | if (ret) | 291 | if (ret) |
291 | break; | 292 | break; |
292 | res.start = res.end + 1; | 293 | res.start = res.end + 1; |