summaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorRoberto Bergantinos Corpas <rbergant@redhat.com>2019-05-28 09:38:14 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-11 12:22:43 +0200
commitdf2b6af4148fde53f0579ae1156160628d049a12 (patch)
treec43ed2550d233eae369627fd132e58268a49201b /fs/cifs
parentcf07331c8827c9e9e0b4274c9b60204c18592241 (diff)
downloadlinux-stable-df2b6af4148fde53f0579ae1156160628d049a12.tar.gz
linux-stable-df2b6af4148fde53f0579ae1156160628d049a12.tar.bz2
linux-stable-df2b6af4148fde53f0579ae1156160628d049a12.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/cifs')
-rw-r--r--fs/cifs/file.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index e7f1773b25d6..df3ee0b6264f 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2892,7 +2892,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;
}