aboutsummaryrefslogtreecommitdiffstats
path: root/lib/swiotlb.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@muc.de>2005-12-20 08:45:19 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-12-20 13:13:54 -0500
commit7e8702334841b6da4b8f564dc1771ca17c59a621 (patch)
tree73f52ad8b0b61a5d863b324041bcc519d7cc5242 /lib/swiotlb.c
parent7ca0b3bf695632003a2a0f98b9fc1451b0483346 (diff)
[PATCH] Fix swiotlb pci_map_sg error handling
The overflow checking condition in lib/swiotlb.c was wrong. It would first run a NULL pointer through virt_to_phys before testing it. Since pci_map_sg overflow is not that uncommon and causes data corruption (including broken file systems) when not properly detected I think it's better to fix it in 2.6.15. This affects x86-64 and IA64. Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'lib/swiotlb.c')
-rw-r--r--lib/swiotlb.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 57216f3544ca..1ff8dcebf7c6 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -704,8 +704,9 @@ swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
704 addr = SG_ENT_VIRT_ADDRESS(sg); 704 addr = SG_ENT_VIRT_ADDRESS(sg);
705 dev_addr = virt_to_phys(addr); 705 dev_addr = virt_to_phys(addr);
706 if (swiotlb_force || address_needs_mapping(hwdev, dev_addr)) { 706 if (swiotlb_force || address_needs_mapping(hwdev, dev_addr)) {
707 sg->dma_address = (dma_addr_t) virt_to_phys(map_single(hwdev, addr, sg->length, dir)); 707 void *map = map_single(hwdev, addr, sg->length, dir);
708 if (!sg->dma_address) { 708 sg->dma_address = virt_to_bus(map);
709 if (!map) {
709 /* Don't panic here, we expect map_sg users 710 /* Don't panic here, we expect map_sg users
710 to do proper error handling. */ 711 to do proper error handling. */
711 swiotlb_full(hwdev, sg->length, dir, 0); 712 swiotlb_full(hwdev, sg->length, dir, 0);