]> xenbits.xensource.com Git - xen.git/commitdiff
vpci: make sure handlers can deal with size == 0
authorRoger Pau Monné <roger.pau@citrix.com>
Tue, 27 Mar 2018 08:28:24 +0000 (10:28 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 27 Mar 2018 08:28:24 +0000 (10:28 +0200)
The code is not prepared to handle such case, so just return early. In
the debug case add an assert.

Coverity ID: 1430809

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/drivers/vpci/vpci.c

index 2913b56500f186014a2775ed79f43ea3bf286df5..82607bdb9ad8eece5435d729b44d2f88e49b7f81 100644 (file)
@@ -320,6 +320,12 @@ uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int size)
     unsigned int data_offset = 0;
     uint32_t data = ~(uint32_t)0;
 
+    if ( !size )
+    {
+        ASSERT_UNREACHABLE();
+        return data;
+    }
+
     /* Find the PCI dev matching the address. */
     pdev = pci_get_pdev_by_domain(d, sbdf.seg, sbdf.bus, sbdf.extfunc);
     if ( !pdev )
@@ -416,6 +422,12 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
     const struct vpci_register *r;
     unsigned int data_offset = 0;
 
+    if ( !size )
+    {
+        ASSERT_UNREACHABLE();
+        return;
+    }
+
     /*
      * Find the PCI dev matching the address.
      * Passthrough everything that's not trapped.