From patchwork Tue Mar 14 10:56:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9623005 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3BB8860244 for ; Tue, 14 Mar 2017 10:57:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E54628159 for ; Tue, 14 Mar 2017 10:57:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23696281B7; Tue, 14 Mar 2017 10:57:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 61F2928538 for ; Tue, 14 Mar 2017 10:57:07 +0000 (UTC) Received: from localhost ([::1]:57741 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnk8X-0000qy-87 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 14 Mar 2017 06:57:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnk8G-0000qS-O8 for qemu-devel@nongnu.org; Tue, 14 Mar 2017 06:56:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnk8C-0000gM-PB for qemu-devel@nongnu.org; Tue, 14 Mar 2017 06:56:48 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:33383) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cnk8C-0000g4-Jd for qemu-devel@nongnu.org; Tue, 14 Mar 2017 06:56:44 -0400 Received: by mail-pg0-x242.google.com with SMTP id 77so23698623pgc.0 for ; Tue, 14 Mar 2017 03:56:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=P237plNH7lCr3Q7UvGVO8dY4SeypY8/d2FJITG2MJ7I=; b=d+FMi7COu0+vR+7vnw6cG0JyksK7wCKapZegpzorRYkiDorLeJKtt72jqf16QNNzxf NQS/yyz3KAVXyTxnbhRvOnw0K1xNSvhp/kGCrYIK0T3z9DKFq2EICL0ds8lKKPvoOVyI c/Y8mM7r6bIS4iOTB5N0Ox1t/TfZjR1tC7xSPYWMo+EIUmQt5p+3S8HN4cZHQkage2iw a3aNOA5tq5wca3b2KE88IszABr8gM3IlRxyCpnUFNDaHjOwsv9/hZGROaFKbS6HBRcl6 jdG7MUcz9GqIWUzsbyHW6lToRuRm0xxq3/paTKosbKNL7MC7jHb55U5rOI6z8UWStbpw Vc8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=P237plNH7lCr3Q7UvGVO8dY4SeypY8/d2FJITG2MJ7I=; b=fNlmTTFb3Xu5pxE3mkZ42+rmvqWhZoKNtpH1cJtjTFXaFOYCTtlgxoXaRduUN21J// xUT8ZylJZ1E+y9B9MrX9MB6XaJnQhGFI5zd/6owozNBYwHU4t+9pWAZwyARnPePcMizK SBAHnVORBi9EMhsb5BJjUtlirEbKZ14Hnp97cuEnVYNMN668N12NijkGJBOk1CLya2hn axpQQ7/Hb3jBbZkvXcXvr7AL+U2jqR1k/OM7poK1zCktxP4RZNTdAwzGW8LfbV5MjBqf w+7h/zwCwFPABxonoDFL0Oe8+N618URfFTfxciWhTIEncUg9zrSxtqcu8IhyW30PgpTn DxUQ== X-Gm-Message-State: AMke39m6mRNrasAfkEnhF5oTLF2iomWy7LTGWAgAvkCToWdixKCBzXvX24D1ZE4ilpQUKw== X-Received: by 10.98.22.87 with SMTP id 84mr43524761pfw.145.1489489003448; Tue, 14 Mar 2017 03:56:43 -0700 (PDT) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id i15sm37980446pfj.0.2017.03.14.03.56.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Mar 2017 03:56:42 -0700 (PDT) From: Li Qiang X-Google-Original-From: Li Qiang To: pbonzini@redhat.com, qemu-devel@nongnu.org Date: Tue, 14 Mar 2017 03:56:20 -0700 Message-Id: <1489488980-130668-1-git-send-email-liqiang6-s@360.cn> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH] scsi: mptsas: fix the wrong reading size in fetch request X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When fetching request, it should read sizeof(*hdr), not the pointer hdr. Signed-off-by: Li Qiang --- hw/scsi/mptsas.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c index 2e091c0..765ab53 100644 --- a/hw/scsi/mptsas.c +++ b/hw/scsi/mptsas.c @@ -756,7 +756,7 @@ static void mptsas_fetch_request(MPTSASState *s) /* Read the message header from the guest first. */ addr = s->host_mfa_high_addr | MPTSAS_FIFO_GET(s, request_post); - pci_dma_read(pci, addr, req, sizeof(hdr)); + pci_dma_read(pci, addr, req, sizeof(*hdr)); if (hdr->Function < ARRAY_SIZE(mpi_request_sizes) && mpi_request_sizes[hdr->Function]) { @@ -766,8 +766,8 @@ static void mptsas_fetch_request(MPTSASState *s) */ size = mpi_request_sizes[hdr->Function]; assert(size <= MPTSAS_MAX_REQUEST_SIZE); - pci_dma_read(pci, addr + sizeof(hdr), &req[sizeof(hdr)], - size - sizeof(hdr)); + pci_dma_read(pci, addr + sizeof(*hdr), &req[sizeof(*hdr)], + size - sizeof(*hdr)); } if (hdr->Function == MPI_FUNCTION_SCSI_IO_REQUEST) {