mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-04 18:19:28 +09:00
CIFS: cifs_read_allocate_pages: don't iterate through whole page array on ENOMEM
commit 31fad7d41e upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f205a91714
commit
dea5d380e2
@@ -2984,7 +2984,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user