Skip to content

Commit

Permalink
cifs: fix allocation in cifs_write_allocate_pages
Browse files Browse the repository at this point in the history
The gfp flags are currently set to __GPF_HIGHMEM, which doesn't allow
for any reclaim. Make this more resilient by or'ing that with
GFP_KERNEL. Also, get rid of the goto and unify the exit codepath.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Acked-by: Pavel Shilovsky <piastry@etersoft.ru>
  • Loading branch information
Jeff Layton committed Mar 23, 2012
1 parent c2e8764 commit e94f7ba
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2045,23 +2045,22 @@ cifs_write_allocate_pages(struct page **pages, unsigned long num_pages)
unsigned long i;

for (i = 0; i < num_pages; i++) {
pages[i] = alloc_page(__GFP_HIGHMEM);
pages[i] = alloc_page(GFP_KERNEL|__GFP_HIGHMEM);
if (!pages[i]) {
/*
* save number of pages we have already allocated and
* return with ENOMEM error
*/
num_pages = i;
rc = -ENOMEM;
goto error;
break;
}
}

return rc;

error:
for (i = 0; i < num_pages; i++)
put_page(pages[i]);
if (rc) {
for (i = 0; i < num_pages; i++)
put_page(pages[i]);
}
return rc;
}

Expand Down

0 comments on commit e94f7ba

Please sign in to comment.