Commit 1b11593e authored by Al Viro's avatar Al Viro Committed by Greg Kroah-Hartman

fix a page leak in vhost_scsi_iov_to_sgl() error recovery

commit 11d49e9d upstream.

we are advancing sg as we go, so the pages we need to drop in
case of error are *before* the current sg.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 509ab500
......@@ -703,6 +703,7 @@ vhost_scsi_iov_to_sgl(struct vhost_scsi_cmd *cmd, bool write,
struct scatterlist *sg, int sg_count)
{
size_t off = iter->iov_offset;
struct scatterlist *p = sg;
int i, ret;
for (i = 0; i < iter->nr_segs; i++) {
......@@ -711,8 +712,8 @@ vhost_scsi_iov_to_sgl(struct vhost_scsi_cmd *cmd, bool write,
ret = vhost_scsi_map_to_sgl(cmd, base, len, sg, write);
if (ret < 0) {
for (i = 0; i < sg_count; i++) {
struct page *page = sg_page(&sg[i]);
while (p < sg) {
struct page *page = sg_page(p++);
if (page)
put_page(page);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment