From 03116d67e0973bb493fe9307e28973a24a272bcc Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Wed, 31 Oct 2007 13:21:29 +0100 Subject: [PATCH] sata_promise: fix endianess bug in ASIC PRD bug workaround The original workaround for the Promise ASIC PRD bug contained an endianess bug which I failed to detect: the adjustment of the last PRD entry's length field applied host arithmetic to little-endian data, which is incorrect on big-endian machines. We have the length available in host-endian format, so do the adjustment on host-endian data and then convert and store it in the PRD entry's little-endian data field. Thanks to an anonymous reviewer for detecting this bug. Signed-off-by: Mikael Pettersson Signed-off-by: Jeff Garzik --- drivers/ata/sata_promise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c index 825e717bce..7914def54f 100644 --- a/drivers/ata/sata_promise.c +++ b/drivers/ata/sata_promise.c @@ -587,7 +587,7 @@ static void pdc_fill_sg(struct ata_queued_cmd *qc) VPRINTK("Splitting last PRD.\n"); addr = le32_to_cpu(ap->prd[idx - 1].addr); - ap->prd[idx - 1].flags_len -= cpu_to_le32(SG_COUNT_ASIC_BUG); + ap->prd[idx - 1].flags_len = cpu_to_le32(len - SG_COUNT_ASIC_BUG); VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", idx - 1, addr, SG_COUNT_ASIC_BUG); addr = addr + len - SG_COUNT_ASIC_BUG; -- 2.39.5