CIFS: cifs_read_allocate_pages: don't iterate through whole page array on ENOMEM
authorRoberto Bergantinos Corpas <rbergant@redhat.com>
Tue, 28 May 2019 07:38:14 +0000 (09:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 9 Jun 2019 07:17:22 +0000 (09:17 +0200)
commit297a251062c0d616e5d6644d4a041532c77d601f
tree95b77a1799cea387707968d6f4758ef436910952
parent32d57c0c063cdab6639da074e8b0f28517862e41
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>
fs/cifs/file.c