Skip to content

Commit

Permalink
sata_promise: fix endianess bug in ASIC PRD bug workaround
Browse files Browse the repository at this point in the history
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 <mikpe@it.uu.se>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
  • Loading branch information
Mikael Pettersson authored and Jeff Garzik committed Nov 3, 2007
1 parent 48166fd commit 03116d6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/ata/sata_promise.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 03116d6

Please sign in to comment.