CIFS: cifs_read_allocate_pages: don't iterate through whole page array on ENOMEM
Subsystems (2)
PATCH 1/1 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 <[email protected]>
--- fs/cifs/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/cifs/file.c +3 -1
@@ -3216,7 +3216,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 ; }
Signature · 1 line
2.14.5