From patchwork Thu Jun 24 03:34:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Zhang X-Patchwork-Id: 56740 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 2FC0FB6F15 for ; Thu, 24 Jun 2010 13:34:36 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754215Ab0FXDef (ORCPT ); Wed, 23 Jun 2010 23:34:35 -0400 Received: from va3ehsobe004.messaging.microsoft.com ([216.32.180.14]:56453 "EHLO VA3EHSOBE004.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754116Ab0FXDee (ORCPT ); Wed, 23 Jun 2010 23:34:34 -0400 Received: from mail150-va3-R.bigfish.com (10.7.14.248) by VA3EHSOBE004.bigfish.com (10.7.40.24) with Microsoft SMTP Server id 8.1.340.0; Thu, 24 Jun 2010 03:34:33 +0000 Received: from mail150-va3 (localhost.localdomain [127.0.0.1]) by mail150-va3-R.bigfish.com (Postfix) with ESMTP id B915AE50070; Thu, 24 Jun 2010 03:34:33 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzzz32i2a8h43h62h) X-Spam-TCS-SCL: 1:0 Received: from mail150-va3 (localhost.localdomain [127.0.0.1]) by mail150-va3 (MessageSwitch) id 1277350473549059_19705; Thu, 24 Jun 2010 03:34:33 +0000 (UTC) Received: from VA3EHSMHS007.bigfish.com (unknown [10.7.14.243]) by mail150-va3.bigfish.com (Postfix) with ESMTP id 81996102804E; Thu, 24 Jun 2010 03:34:33 +0000 (UTC) Received: from ausb3extmailp01.amd.com (163.181.251.8) by VA3EHSMHS007.bigfish.com (10.7.99.17) with Microsoft SMTP Server (TLS) id 14.0.482.44; Thu, 24 Jun 2010 03:34: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 o5O3c9E1015390; Wed, 23 Jun 2010 22:38:12 -0500 X-WSS-ID: 0L4I1XD-02-GQW-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 2618EC8895; Wed, 23 Jun 2010 22:34:25 -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; Wed, 23 Jun 2010 22:34:28 -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; Wed, 23 Jun 2010 23:34:27 -0400 Received: from sshaexmb1.amd.com ([10.237.2.11]) by storexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 23 Jun 2010 23:34:27 -0400 Received: from 10.237.82.10 ([10.237.82.10]) by sshaexmb1.amd.com ([10.237.2.11]) with Microsoft Exchange Server HTTP-DAV ; Thu, 24 Jun 2010 03:34:23 +0000 Received: from zm-desktop by sshaexmb1.amd.com; 24 Jun 2010 11:34:24 +0800 Subject: [PATCH #upstream-fixes] 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 Date: Thu, 24 Jun 2010 11:34:23 +0800 Message-ID: <1277350463.8158.3.camel@zm-desktop> MIME-Version: 1.0 X-Mailer: Evolution 2.26.1 X-OriginalArrivalTime: 24 Jun 2010 03:34:27.0064 (UTC) FILETIME=[25ACA780:01CB134E] 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 | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index 1984a6e..7b273f0 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); }