libahci: Fix bug in storing EM messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 drivers/ata/libahci.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 1984a6e..09a9b51 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -324,7 +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;
-	u32 em_ctl, msg;
+	u32 em_ctl, *msg_buf = (u32 *)buf;
 	unsigned long flags;
 	int i;
 
@@ -342,11 +342,8 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
 		return -EBUSY;
 	}
 
-	for (i = 0; i < size; i += 4) {
-		msg = buf[i] | buf[i + 1] << 8 |
-		      buf[i + 2] << 16 | buf[i + 3] << 24;
-		writel(msg, em_mmio + i);
-	}
+	for (i = 0; i < size; i += 4)
+		writel(msg_buf[i >> 2], em_mmio + i);
 
 	writel(em_ctl | EM_CTL_TM, mmio + HOST_EM_CTL);
 
-- 
1.6.4.2



--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux