From patchwork Fri Jan 29 21:41:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 8167681 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 244CD9F440 for ; Fri, 29 Jan 2016 21:41:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8E70920221 for ; Fri, 29 Jan 2016 21:41:47 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id F36D720381 for ; Fri, 29 Jan 2016 21:41:45 +0000 (UTC) Received: from localhost ([::1]:36572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPGnX-0000gl-Hc for patchwork-qemu-devel@patchwork.kernel.org; Fri, 29 Jan 2016 16:41:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPGnP-0000dS-GC for qemu-devel@nongnu.org; Fri, 29 Jan 2016 16:41:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPGnO-0008BR-Pe for qemu-devel@nongnu.org; Fri, 29 Jan 2016 16:41:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPGnM-0008Ab-Nu; Fri, 29 Jan 2016 16:41:32 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 471513BEB5; Fri, 29 Jan 2016 21:41:32 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0TLfUMQ009641; Fri, 29 Jan 2016 16:41:31 -0500 From: John Snow To: qemu-block@nongnu.org Date: Fri, 29 Jan 2016 16:41:26 -0500 Message-Id: <1454103689-13042-2-git-send-email-jsnow@redhat.com> In-Reply-To: <1454103689-13042-1-git-send-email-jsnow@redhat.com> References: <1454103689-13042-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, pjp@fedoraproject.org, qemu-devel@nongnu.org, zuozhi.fzz@alibaba-inc.com, pbonzini@redhat.com, John Snow Subject: [Qemu-devel] [PATCH 1/4] ahci: Do not unmap NULL addresses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Definitely don't try to unmap a garbage address. Reported-by: Zuozhi fzz Signed-off-by: John Snow --- hw/ide/ahci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 17f1cbd..cdc9299 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -661,6 +661,10 @@ static bool ahci_map_fis_address(AHCIDevice *ad) static void ahci_unmap_fis_address(AHCIDevice *ad) { + if (ad->res_fis == NULL) { + DPRINTF(ad->port_no, "Attempt to unmap NULL FIS address\n"); + return; + } dma_memory_unmap(ad->hba->as, ad->res_fis, 256, DMA_DIRECTION_FROM_DEVICE, 256); ad->res_fis = NULL; @@ -677,6 +681,10 @@ static bool ahci_map_clb_address(AHCIDevice *ad) static void ahci_unmap_clb_address(AHCIDevice *ad) { + if (ad->lst == NULL) { + DPRINTF(ad->port_no, "Attempt to unmap NULL CLB address\n"); + return; + } dma_memory_unmap(ad->hba->as, ad->lst, 1024, DMA_DIRECTION_FROM_DEVICE, 1024); ad->lst = NULL;