summaryrefslogtreecommitdiff
path: root/drivers/ata
diff options
context:
space:
mode:
authorHarry Zhang <harry.zhang@amd.com>2010-06-24 11:34:23 +0800
committerJeff Garzik <jgarzik@redhat.com>2010-07-01 15:34:15 -0400
commitf9ce889b8f8384ee29e1be4b34091a932e6e40f3 (patch)
treeed9b189cf639e2dcfa144cd840c0e0efa55f838a /drivers/ata
parent984bc9601f64fd341b8573021d7c999f1f1499a9 (diff)
downloadlinux-3.10-f9ce889b8f8384ee29e1be4b34091a932e6e40f3.tar.gz
linux-3.10-f9ce889b8f8384ee29e1be4b34091a932e6e40f3.tar.bz2
linux-3.10-f9ce889b8f8384ee29e1be4b34091a932e6e40f3.zip
libahci: Fix bug in storing EM messages
In function ahci_store_em_buffer(), if the input (signed char*) buffer contains negative data, the constructed 32-bit long message data may be wrong. Signed-off-by: Harry Zhang <harry.zhang@amd.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libahci.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 261f86d102e..81e772a94d5 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -324,6 +324,7 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
struct ahci_host_priv *hpriv = ap->host->private_data;
void __iomem *mmio = hpriv->mmio;
void __iomem *em_mmio = mmio + hpriv->em_loc;
+ const unsigned char *msg_buf = buf;
u32 em_ctl, msg;
unsigned long flags;
int i;
@@ -343,8 +344,8 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
}
for (i = 0; i < size; i += 4) {
- msg = buf[i] | buf[i + 1] << 8 |
- buf[i + 2] << 16 | buf[i + 3] << 24;
+ msg = msg_buf[i] | msg_buf[i + 1] << 8 |
+ msg_buf[i + 2] << 16 | msg_buf[i + 3] << 24;
writel(msg, em_mmio + i);
}