Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 180714
b: refs/heads/master
c: d13536b
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Feb 21, 2010
1 parent f6bc998 commit 8a50256
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3dae93ec3ee1fceec69f40ef9b97892ce62ba7a5
refs/heads/master: d13536bef4b42d3e24f5ae2429722d008c60e3fc
36 changes: 15 additions & 21 deletions trunk/mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,33 +1002,27 @@ static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages,
#define DO_PAGES_STAT_CHUNK_NR 16
const void __user *chunk_pages[DO_PAGES_STAT_CHUNK_NR];
int chunk_status[DO_PAGES_STAT_CHUNK_NR];
unsigned long i, chunk_nr = DO_PAGES_STAT_CHUNK_NR;
int err;

for (i = 0; i < nr_pages; i += chunk_nr) {
if (chunk_nr > nr_pages - i)
chunk_nr = nr_pages - i;
while (nr_pages) {
unsigned long chunk_nr;

err = copy_from_user(chunk_pages, &pages[i],
chunk_nr * sizeof(*chunk_pages));
if (err) {
err = -EFAULT;
goto out;
}
chunk_nr = nr_pages;
if (chunk_nr > DO_PAGES_STAT_CHUNK_NR)
chunk_nr = DO_PAGES_STAT_CHUNK_NR;

if (copy_from_user(chunk_pages, pages, chunk_nr * sizeof(*chunk_pages)))
break;

do_pages_stat_array(mm, chunk_nr, chunk_pages, chunk_status);

err = copy_to_user(&status[i], chunk_status,
chunk_nr * sizeof(*chunk_status));
if (err) {
err = -EFAULT;
goto out;
}
}
err = 0;
if (copy_to_user(status, chunk_status, chunk_nr * sizeof(*status)))
break;

out:
return err;
pages += chunk_nr;
status += chunk_nr;
nr_pages -= chunk_nr;
}
return nr_pages ? -EFAULT : 0;
}

/*
Expand Down

0 comments on commit 8a50256

Please sign in to comment.