From patchwork Fri Jun 11 07:44:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Zhang X-Patchwork-Id: 55296 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 89016B7D5B for ; Fri, 11 Jun 2010 17:47:39 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754637Ab0FKHri (ORCPT ); Fri, 11 Jun 2010 03:47:38 -0400 Received: from tx2ehsobe003.messaging.microsoft.com ([65.55.88.13]:10842 "EHLO TX2EHSOBE005.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752969Ab0FKHrh (ORCPT ); Fri, 11 Jun 2010 03:47:37 -0400 Received: from mail52-tx2-R.bigfish.com (10.9.14.251) by TX2EHSOBE005.bigfish.com (10.9.40.25) with Microsoft SMTP Server id 8.1.340.0; Fri, 11 Jun 2010 07:47:34 +0000 Received: from mail52-tx2 (localhost.localdomain [127.0.0.1]) by mail52-tx2-R.bigfish.com (Postfix) with ESMTP id D50F218A024F; Fri, 11 Jun 2010 07:47:33 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzzz32i2a8h43h64h) X-Spam-TCS-SCL: 3:0 Received: from mail52-tx2 (localhost.localdomain [127.0.0.1]) by mail52-tx2 (MessageSwitch) id 1276242453632599_22678; Fri, 11 Jun 2010 07:47:33 +0000 (UTC) Received: from TX2EHSMHS015.bigfish.com (unknown [10.9.14.243]) by mail52-tx2.bigfish.com (Postfix) with ESMTP id 9473A910050; Fri, 11 Jun 2010 07:47:33 +0000 (UTC) Received: from ausb3extmailp01.amd.com (163.181.251.8) by TX2EHSMHS015.bigfish.com (10.9.99.115) with Microsoft SMTP Server (TLS) id 14.0.482.44; Fri, 11 Jun 2010 07:47:33 +0000 Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp01.amd.com (Switch-3.2.7/Switch-3.2.7) with SMTP id o5B7QgFh014282; Fri, 11 Jun 2010 02:26:45 -0500 X-WSS-ID: 0L3UATR-02-BQV-02 X-M-MSG: Received: from sausexhtp02.amd.com (sausexhtp02.amd.com [163.181.3.152]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 22115C8A1E; Fri, 11 Jun 2010 02:44:14 -0500 (CDT) Received: from storexhtp01.amd.com (172.24.4.3) by sausexhtp02.amd.com (163.181.3.152) with Microsoft SMTP Server (TLS) id 8.2.254.0; Fri, 11 Jun 2010 02:44:19 -0500 Received: from storexbh1.amd.com (10.1.1.17) by storexhtp01.amd.com (172.24.4.3) with Microsoft SMTP Server id 8.2.254.0; Fri, 11 Jun 2010 03:44:17 -0400 Received: from sshaexmb1.amd.com ([10.237.2.11]) by storexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 11 Jun 2010 03:44:17 -0400 Received: from 10.237.82.16 ([10.237.82.16]) by sshaexmb1.amd.com ([10.237.2.11]) with Microsoft Exchange Server HTTP-DAV ; Fri, 11 Jun 2010 07:44:12 +0000 Received: from zm-desktop by sshaexmb1.amd.com; 11 Jun 2010 15:44:12 +0800 Subject: libahci: Fix bug in storing EM messages From: Harry Zhang To: jgarzik@pobox.com CC: linux-ide@vger.kernel.org, tj@kernel.org, shane.huang@amd.com, Zhang@domain.invalid, Harry Date: Fri, 11 Jun 2010 15:44:12 +0800 Message-ID: <1276242252.14959.8.camel@zm-desktop> MIME-Version: 1.0 X-Mailer: Evolution 2.26.1 X-OriginalArrivalTime: 11 Jun 2010 07:44:17.0486 (UTC) FILETIME=[E54AC6E0:01CB0939] X-Reverse-DNS: unknown Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org 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 --- 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);