aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2009-08-16 08:21:21 -0400
committerJeff Garzik <jgarzik@redhat.com>2009-09-08 21:18:03 -0400
commitac8672ea922bde59acf50eaa1eaa1640a6395fd2 (patch)
tree056d44a2b81151a42f4ac31df1ae9f90483e220f /drivers/ata
parent1b549dcbf607e88f3016bc149109472a46fe7bbb (diff)
libata: fix off-by-one error in ata_tf_read_block()
ata_tf_read_block() has off-by-one error when converting CHS address to LBA. The bug isn't very visible because ata_tf_read_block() is used only when generating sense data for a failed RW command and CHS addressing isn't used too often these days. This problem was spotted by Atsushi Nemoto. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-core.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 98af50f16e0c..df31deac5c82 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -709,7 +709,13 @@ u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev)
709 head = tf->device & 0xf; 709 head = tf->device & 0xf;
710 sect = tf->lbal; 710 sect = tf->lbal;
711 711
712 block = (cyl * dev->heads + head) * dev->sectors + sect; 712 if (!sect) {
713 ata_dev_printk(dev, KERN_WARNING, "device reported "
714 "invalid CHS sector 0\n");
715 sect = 1; /* oh well */
716 }
717
718 block = (cyl * dev->heads + head) * dev->sectors + sect - 1;
713 } 719 }
714 720
715 return block; 721 return block;