Skip to content

Commit

Permalink
CIFS: cifs_read_allocate_pages: don't iterate through whole page arra…
Browse files Browse the repository at this point in the history
…y on ENOMEM

 In cifs_read_allocate_pages, in case of ENOMEM, we go through
whole rdata->pages array but we have failed the allocation before
nr_pages, therefore we may end up calling put_page with NULL
pointer, causing oops

Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
Acked-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
CC: Stable <stable@vger.kernel.org>
  • Loading branch information
Roberto Bergantinos Corpas authored and Steve French committed May 29, 2019
1 parent 50fbc13 commit 31fad7d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3216,7 +3216,9 @@ cifs_read_allocate_pages(struct cifs_readdata *rdata, unsigned int nr_pages)
}

if (rc) {
for (i = 0; i < nr_pages; i++) {
unsigned int nr_page_failed = i;

for (i = 0; i < nr_page_failed; i++) {
put_page(rdata->pages[i]);
rdata->pages[i] = NULL;
}
Expand Down

0 comments on commit 31fad7d

Please sign in to comment.