[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 <hugh@veritas.com>
Signed-off-by: Douglas Gilbert <dougg@torque.net>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by Hugh Dickins and committed by James Bottomley 4d5cda06 032c09d7

+3 -1
+3 -1
drivers/scsi/sg.c
··· 1860 unlock_page(pages[j]); */ 1861 res = 0; 1862 out_unmap: 1863 - if (res > 0) 1864 for (j=0; j < res; j++) 1865 page_cache_release(pages[j]); 1866 kfree(pages); 1867 return res; 1868 }
··· 1860 unlock_page(pages[j]); */ 1861 res = 0; 1862 out_unmap: 1863 + if (res > 0) { 1864 for (j=0; j < res; j++) 1865 page_cache_release(pages[j]); 1866 + res = 0; 1867 + } 1868 kfree(pages); 1869 return res; 1870 }