Commit f9ce889b authored by Harry Zhang's avatar Harry Zhang Committed by Jeff Garzik

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: default avatarHarry Zhang <harry.zhang@amd.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 984bc960
...@@ -324,6 +324,7 @@ static ssize_t ahci_store_em_buffer(struct device *dev, ...@@ -324,6 +324,7 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
struct ahci_host_priv *hpriv = ap->host->private_data; struct ahci_host_priv *hpriv = ap->host->private_data;
void __iomem *mmio = hpriv->mmio; void __iomem *mmio = hpriv->mmio;
void __iomem *em_mmio = mmio + hpriv->em_loc; void __iomem *em_mmio = mmio + hpriv->em_loc;
const unsigned char *msg_buf = buf;
u32 em_ctl, msg; u32 em_ctl, msg;
unsigned long flags; unsigned long flags;
int i; int i;
...@@ -343,8 +344,8 @@ static ssize_t ahci_store_em_buffer(struct device *dev, ...@@ -343,8 +344,8 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
} }
for (i = 0; i < size; i += 4) { for (i = 0; i < size; i += 4) {
msg = buf[i] | buf[i + 1] << 8 | msg = msg_buf[i] | msg_buf[i + 1] << 8 |
buf[i + 2] << 16 | buf[i + 3] << 24; msg_buf[i + 2] << 16 | msg_buf[i + 3] << 24;
writel(msg, em_mmio + i); writel(msg, em_mmio + i);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment