diff options
| author | Roberto Bergantinos Corpas <rbergant@redhat.com> | 2019-05-28 03:38:14 -0400 |
|---|---|---|
| committer | Steve French <stfrench@microsoft.com> | 2019-05-29 15:02:11 -0400 |
| commit | 31fad7d41e73731f05b8053d17078638cf850fa6 (patch) | |
| tree | a3f2c3ddb1bc7355b7fb2c1769d1ff428acc489a | |
| parent | 50fbc13dc12666f3604dc2555a47fc8c4e29162b (diff) | |
CIFS: cifs_read_allocate_pages: don't iterate through whole page array 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>
| -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 ce9a5be11df5..06e27ac6d82c 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
| @@ -3216,7 +3216,9 @@ cifs_read_allocate_pages(struct cifs_readdata *rdata, unsigned int nr_pages) | |||
| 3216 | } | 3216 | } |
| 3217 | 3217 | ||
| 3218 | if (rc) { | 3218 | if (rc) { |
| 3219 | for (i = 0; i < nr_pages; i++) { | 3219 | unsigned int nr_page_failed = i; |
| 3220 | |||
| 3221 | for (i = 0; i < nr_page_failed; i++) { | ||
| 3220 | put_page(rdata->pages[i]); | 3222 | put_page(rdata->pages[i]); |
| 3221 | rdata->pages[i] = NULL; | 3223 | rdata->pages[i] = NULL; |
| 3222 | } | 3224 | } |
