diff options
author | Roberto Bergantinos Corpas <rbergant@redhat.com> | 2019-05-28 09:38:14 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-06-09 09:17:22 +0200 |
commit | 297a251062c0d616e5d6644d4a041532c77d601f (patch) | |
tree | 95b77a1799cea387707968d6f4758ef436910952 /fs | |
parent | 32d57c0c063cdab6639da074e8b0f28517862e41 (diff) | |
download | linux-rpi3-297a251062c0d616e5d6644d4a041532c77d601f.tar.gz linux-rpi3-297a251062c0d616e5d6644d4a041532c77d601f.tar.bz2 linux-rpi3-297a251062c0d616e5d6644d4a041532c77d601f.zip |
CIFS: cifs_read_allocate_pages: don't iterate through whole page array on ENOMEM
commit 31fad7d41e73731f05b8053d17078638cf850fa6 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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/file.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index d6b45682833b..23cee91ed442 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2988,7 +2988,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; } |