diff options
author | K. Y. Srinivasan <kys@microsoft.com> | 2015-03-27 03:27:18 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Odin.com> | 2015-04-09 16:22:12 -0400 |
commit | 8de580742fee8bc34d116f57a20b22b9a5f08403 (patch) | |
tree | 847ee1044da7b2f5ca0b2b255710faa392c064e7 | |
parent | 5117b93696fae092be92acf1b80ae19cb28f4ba3 (diff) |
scsi: storvsc: Fix a bug in copy_from_bounce_buffer()
We may exit this function without properly freeing up the maapings
we may have acquired. Fix the bug.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Long Li <longli@microsoft.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
-rw-r--r-- | drivers/scsi/storvsc_drv.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index cdf048ba4d2d..f8e4dd925a9d 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c | |||
@@ -754,21 +754,22 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl, | |||
754 | if (bounce_sgl[j].length == PAGE_SIZE) { | 754 | if (bounce_sgl[j].length == PAGE_SIZE) { |
755 | /* full..move to next entry */ | 755 | /* full..move to next entry */ |
756 | sg_kunmap_atomic(bounce_addr); | 756 | sg_kunmap_atomic(bounce_addr); |
757 | bounce_addr = 0; | ||
757 | j++; | 758 | j++; |
759 | } | ||
758 | 760 | ||
759 | /* if we need to use another bounce buffer */ | 761 | /* if we need to use another bounce buffer */ |
760 | if (srclen || i != orig_sgl_count - 1) | 762 | if (srclen && bounce_addr == 0) |
761 | bounce_addr = sg_kmap_atomic(bounce_sgl,j); | 763 | bounce_addr = sg_kmap_atomic(bounce_sgl, j); |
762 | 764 | ||
763 | } else if (srclen == 0 && i == orig_sgl_count - 1) { | ||
764 | /* unmap the last bounce that is < PAGE_SIZE */ | ||
765 | sg_kunmap_atomic(bounce_addr); | ||
766 | } | ||
767 | } | 765 | } |
768 | 766 | ||
769 | sg_kunmap_atomic(src_addr - orig_sgl[i].offset); | 767 | sg_kunmap_atomic(src_addr - orig_sgl[i].offset); |
770 | } | 768 | } |
771 | 769 | ||
770 | if (bounce_addr) | ||
771 | sg_kunmap_atomic(bounce_addr); | ||
772 | |||
772 | local_irq_restore(flags); | 773 | local_irq_restore(flags); |
773 | 774 | ||
774 | return total_copied; | 775 | return total_copied; |