Skip to content

Commit

Permalink
[SCSI] sg: fix a bug in st_map_user_pages failure path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hugh Dickins authored and James Bottomley committed Dec 2, 2005
1 parent 032c09d commit 4d5cda0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4d5cda0

Please sign in to comment.