提交 b50e56d8 编写于 作者: A Al Viro 提交者: Jeff Garzik

libata fixes for sparse-found problems

In pata_legacy and pata_winbond we've got bugs - cpu_to_le16() instead
of cpu_to_le32().  Fortunately, both affected suckers are VLB, thus
l-e-only, so we might get away with that unless we hit it with slop == 3
(hadn't checked if playing with badly aligned sg could trigger that).
Still buggy...  Moreover, pata_legacy, pata_winbond and pata_qdi forgot to
initialize pad on the write side of 32bit case in their ->data_xfer().
Hopefully the hardware does't care, but still, sending uninitialized
data to it...
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: NJeff Garzik <jeff@garzik.org>
上级 38ad9aeb
...@@ -271,14 +271,12 @@ static void pdc_data_xfer_vlb(struct ata_device *adev, unsigned char *buf, unsig ...@@ -271,14 +271,12 @@ static void pdc_data_xfer_vlb(struct ata_device *adev, unsigned char *buf, unsig
ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
if (unlikely(slop)) { if (unlikely(slop)) {
u32 pad; __le32 pad = 0;
if (write_data) { if (write_data) {
memcpy(&pad, buf + buflen - slop, slop); memcpy(&pad, buf + buflen - slop, slop);
pad = le32_to_cpu(pad); iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr);
iowrite32(pad, ap->ioaddr.data_addr);
} else { } else {
pad = ioread32(ap->ioaddr.data_addr); pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
pad = cpu_to_le16(pad);
memcpy(buf + buflen - slop, &pad, slop); memcpy(buf + buflen - slop, &pad, slop);
} }
} }
......
...@@ -136,14 +136,12 @@ static void qdi_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned ...@@ -136,14 +136,12 @@ static void qdi_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned
ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
if (unlikely(slop)) { if (unlikely(slop)) {
u32 pad; __le32 pad = 0;
if (write_data) { if (write_data) {
memcpy(&pad, buf + buflen - slop, slop); memcpy(&pad, buf + buflen - slop, slop);
pad = le32_to_cpu(pad); iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr);
iowrite32(pad, ap->ioaddr.data_addr);
} else { } else {
pad = ioread32(ap->ioaddr.data_addr); pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
pad = cpu_to_le32(pad);
memcpy(buf + buflen - slop, &pad, slop); memcpy(buf + buflen - slop, &pad, slop);
} }
} }
......
...@@ -104,14 +104,12 @@ static void winbond_data_xfer(struct ata_device *adev, unsigned char *buf, unsig ...@@ -104,14 +104,12 @@ static void winbond_data_xfer(struct ata_device *adev, unsigned char *buf, unsig
ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
if (unlikely(slop)) { if (unlikely(slop)) {
u32 pad; __le32 pad = 0;
if (write_data) { if (write_data) {
memcpy(&pad, buf + buflen - slop, slop); memcpy(&pad, buf + buflen - slop, slop);
pad = le32_to_cpu(pad); iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr);
iowrite32(pad, ap->ioaddr.data_addr);
} else { } else {
pad = ioread32(ap->ioaddr.data_addr); pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
pad = cpu_to_le16(pad);
memcpy(buf + buflen - slop, &pad, slop); memcpy(buf + buflen - slop, &pad, slop);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册