diff options
Diffstat (limited to 'mm/migrate.c')
-rw-r--r-- | mm/migrate.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/mm/migrate.c b/mm/migrate.c index 9a0db5bbabe4..880bd592d38e 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
@@ -1002,33 +1002,27 @@ static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages, | |||
1002 | #define DO_PAGES_STAT_CHUNK_NR 16 | 1002 | #define DO_PAGES_STAT_CHUNK_NR 16 |
1003 | const void __user *chunk_pages[DO_PAGES_STAT_CHUNK_NR]; | 1003 | const void __user *chunk_pages[DO_PAGES_STAT_CHUNK_NR]; |
1004 | int chunk_status[DO_PAGES_STAT_CHUNK_NR]; | 1004 | int chunk_status[DO_PAGES_STAT_CHUNK_NR]; |
1005 | unsigned long i, chunk_nr = DO_PAGES_STAT_CHUNK_NR; | ||
1006 | int err; | ||
1007 | 1005 | ||
1008 | for (i = 0; i < nr_pages; i += chunk_nr) { | 1006 | while (nr_pages) { |
1009 | if (chunk_nr > nr_pages - i) | 1007 | unsigned long chunk_nr; |
1010 | chunk_nr = nr_pages - i; | ||
1011 | 1008 | ||
1012 | err = copy_from_user(chunk_pages, &pages[i], | 1009 | chunk_nr = nr_pages; |
1013 | chunk_nr * sizeof(*chunk_pages)); | 1010 | if (chunk_nr > DO_PAGES_STAT_CHUNK_NR) |
1014 | if (err) { | 1011 | chunk_nr = DO_PAGES_STAT_CHUNK_NR; |
1015 | err = -EFAULT; | 1012 | |
1016 | goto out; | 1013 | if (copy_from_user(chunk_pages, pages, chunk_nr * sizeof(*chunk_pages))) |
1017 | } | 1014 | break; |
1018 | 1015 | ||
1019 | do_pages_stat_array(mm, chunk_nr, chunk_pages, chunk_status); | 1016 | do_pages_stat_array(mm, chunk_nr, chunk_pages, chunk_status); |
1020 | 1017 | ||
1021 | err = copy_to_user(&status[i], chunk_status, | 1018 | if (copy_to_user(status, chunk_status, chunk_nr * sizeof(*status))) |
1022 | chunk_nr * sizeof(*chunk_status)); | 1019 | break; |
1023 | if (err) { | ||
1024 | err = -EFAULT; | ||
1025 | goto out; | ||
1026 | } | ||
1027 | } | ||
1028 | err = 0; | ||
1029 | 1020 | ||
1030 | out: | 1021 | pages += chunk_nr; |
1031 | return err; | 1022 | status += chunk_nr; |
1023 | nr_pages -= chunk_nr; | ||
1024 | } | ||
1025 | return nr_pages ? -EFAULT : 0; | ||
1032 | } | 1026 | } |
1033 | 1027 | ||
1034 | /* | 1028 | /* |