Skip to content

Commit

Permalink
libahci: Fix bug in storing EM messages
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Harry Zhang authored and Jeff Garzik committed Jul 1, 2010
1 parent 984bc96 commit f9ce889
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/ata/libahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down

0 comments on commit f9ce889

Please sign in to comment.