From: Hugh Dickins Date: Fri, 2 Dec 2005 15:58:09 +0000 (+0000) Subject: [SCSI] sg: fix a bug in st_map_user_pages failure path X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4d5cda069b3f0a3bbc18576bc15903ed665d0295;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git [SCSI] sg: fix a bug in st_map_user_pages failure path sg's st_map_user_pages is modelled on an earlier version of st's sgl_map_user_pages, and has the same bug: if get_user_pages got some but not all of the pages, then those got were released, but the positive res code returned implied that they were still to be freed. Signed-off-by: Hugh Dickins Signed-off-by: Douglas Gilbert Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 6de7ff9faf2..b55c2a8a547 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1860,9 +1860,11 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, unlock_page(pages[j]); */ res = 0; out_unmap: - if (res > 0) + if (res > 0) { for (j=0; j < res; j++) page_cache_release(pages[j]); + res = 0; + } kfree(pages); return res; }