]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
ahci: Do not unmap NULL addresses
authorJohn Snow <jsnow@redhat.com>
Wed, 10 Feb 2016 18:29:40 +0000 (13:29 -0500)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 22 Mar 2016 22:35:36 +0000 (17:35 -0500)
Definitely don't try to unmap a garbage address.

Reported-by: Zuozhi fzz <zuozhi.fzz@alibaba-inc.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1454103689-13042-2-git-send-email-jsnow@redhat.com
(cherry picked from commit 99b4cb71069f109b79b27bc629fc0cf0886dbc4b)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/ide/ahci.c

index dd1912e80d76821a24569758e792d6766172da0b..d47ceeb89a12463e22e87d35d6ac13df34096983 100644 (file)
@@ -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;