Blame 0012-ahci-Do-not-unmap-NULL-addresses.patch

7d975d
From: John Snow <jsnow@redhat.com>
7d975d
Date: Wed, 10 Feb 2016 13:29:40 -0500
7d975d
Subject: [PATCH] ahci: Do not unmap NULL addresses
7d975d
7d975d
Definitely don't try to unmap a garbage address.
7d975d
7d975d
Reported-by: Zuozhi fzz <zuozhi.fzz@alibaba-inc.com>
7d975d
Signed-off-by: John Snow <jsnow@redhat.com>
7d975d
Message-id: 1454103689-13042-2-git-send-email-jsnow@redhat.com
7d975d
(cherry picked from commit 99b4cb71069f109b79b27bc629fc0cf0886dbc4b)
7d975d
---
7d975d
 hw/ide/ahci.c | 8 ++++++++
7d975d
 1 file changed, 8 insertions(+)
7d975d
7d975d
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
7d975d
index 17f1cbd..cdc9299 100644
7d975d
--- a/hw/ide/ahci.c
7d975d
+++ b/hw/ide/ahci.c
7d975d
@@ -661,6 +661,10 @@ static bool ahci_map_fis_address(AHCIDevice *ad)
7d975d
 
7d975d
 static void ahci_unmap_fis_address(AHCIDevice *ad)
7d975d
 {
7d975d
+    if (ad->res_fis == NULL) {
7d975d
+        DPRINTF(ad->port_no, "Attempt to unmap NULL FIS address\n");
7d975d
+        return;
7d975d
+    }
7d975d
     dma_memory_unmap(ad->hba->as, ad->res_fis, 256,
7d975d
                      DMA_DIRECTION_FROM_DEVICE, 256);
7d975d
     ad->res_fis = NULL;
7d975d
@@ -677,6 +681,10 @@ static bool ahci_map_clb_address(AHCIDevice *ad)
7d975d
 
7d975d
 static void ahci_unmap_clb_address(AHCIDevice *ad)
7d975d
 {
7d975d
+    if (ad->lst == NULL) {
7d975d
+        DPRINTF(ad->port_no, "Attempt to unmap NULL CLB address\n");
7d975d
+        return;
7d975d
+    }
7d975d
     dma_memory_unmap(ad->hba->as, ad->lst, 1024,
7d975d
                      DMA_DIRECTION_FROM_DEVICE, 1024);
7d975d
     ad->lst = NULL;