Commit 83911b9e authored by K. Y. Srinivasan's avatar K. Y. Srinivasan Committed by Ben Hutchings

scsi: storvsc: Fix a bug in copy_from_bounce_buffer()

commit 8de58074 upstream.

We may exit this function without properly freeing up the maapings
we may have acquired. Fix the bug.
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: default avatarLong Li <longli@microsoft.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Odin.com>
[bwh: Backported to 3.2:
 - Adjust filename
 - Keep using kmap_atomic()/kunmap_atomic(), not the sg_-prefixed functions]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 1ea590d4
......@@ -940,23 +940,24 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
if (bounce_sgl[j].length == PAGE_SIZE) {
/* full..move to next entry */
kunmap_atomic((void *)bounce_addr, KM_IRQ0);
bounce_addr = 0;
j++;
}
/* if we need to use another bounce buffer */
if (srclen || i != orig_sgl_count - 1)
if (srclen && bounce_addr == 0)
bounce_addr =
(unsigned long)kmap_atomic(
sg_page((&bounce_sgl[j])), KM_IRQ0);
} else if (srclen == 0 && i == orig_sgl_count - 1) {
/* unmap the last bounce that is < PAGE_SIZE */
kunmap_atomic((void *)bounce_addr, KM_IRQ0);
}
}
kunmap_atomic((void *)(src_addr - orig_sgl[i].offset), KM_IRQ0);
}
if (bounce_addr)
kunmap_atomic((void *)bounce_addr, KM_IRQ0);
local_irq_restore(flags);
return total_copied;
......
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