Skip to content

Commit 8de5807

Browse files
kattisrinivasanJames Bottomley
authored and
James Bottomley
committed
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 <[email protected]> Reviewed-by: Long Li <[email protected]> Cc: <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent 5117b93 commit 8de5807

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/scsi/storvsc_drv.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -754,21 +754,22 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
754754
if (bounce_sgl[j].length == PAGE_SIZE) {
755755
/* full..move to next entry */
756756
sg_kunmap_atomic(bounce_addr);
757+
bounce_addr = 0;
757758
j++;
759+
}
758760

759-
/* if we need to use another bounce buffer */
760-
if (srclen || i != orig_sgl_count - 1)
761-
bounce_addr = sg_kmap_atomic(bounce_sgl,j);
761+
/* if we need to use another bounce buffer */
762+
if (srclen && bounce_addr == 0)
763+
bounce_addr = sg_kmap_atomic(bounce_sgl, j);
762764

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-
}
767765
}
768766

769767
sg_kunmap_atomic(src_addr - orig_sgl[i].offset);
770768
}
771769

770+
if (bounce_addr)
771+
sg_kunmap_atomic(bounce_addr);
772+
772773
local_irq_restore(flags);
773774

774775
return total_copied;

0 commit comments

Comments
 (0)