Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc
[linux-2.6.git] / drivers / pci / xen-pcifront.c
index 030ce37..492b7d8 100644 (file)
@@ -243,7 +243,7 @@ struct pci_ops pcifront_bus_ops = {
 
 #ifdef CONFIG_PCI_MSI
 static int pci_frontend_enable_msix(struct pci_dev *dev,
-                                   int **vector, int nvec)
+                                   int vector[], int nvec)
 {
        int err;
        int i;
@@ -277,18 +277,24 @@ static int pci_frontend_enable_msix(struct pci_dev *dev,
        if (likely(!err)) {
                if (likely(!op.value)) {
                        /* we get the result */
-                       for (i = 0; i < nvec; i++)
-                               *(*vector+i) = op.msix_entries[i].vector;
-                       return 0;
+                       for (i = 0; i < nvec; i++) {
+                               if (op.msix_entries[i].vector <= 0) {
+                                       dev_warn(&dev->dev, "MSI-X entry %d is invalid: %d!\n",
+                                               i, op.msix_entries[i].vector);
+                                       err = -EINVAL;
+                                       vector[i] = -1;
+                                       continue;
+                               }
+                               vector[i] = op.msix_entries[i].vector;
+                       }
                } else {
                        printk(KERN_DEBUG "enable msix get value %x\n",
                                op.value);
-                       return op.value;
                }
        } else {
                dev_err(&dev->dev, "enable msix get err %x\n", err);
-               return err;
        }
+       return err;
 }
 
 static void pci_frontend_disable_msix(struct pci_dev *dev)
@@ -310,7 +316,7 @@ static void pci_frontend_disable_msix(struct pci_dev *dev)
                dev_err(&dev->dev, "pci_disable_msix get err %x\n", err);
 }
 
-static int pci_frontend_enable_msi(struct pci_dev *dev, int **vector)
+static int pci_frontend_enable_msi(struct pci_dev *dev, int vector[])
 {
        int err;
        struct xen_pci_op op = {
@@ -324,7 +330,13 @@ static int pci_frontend_enable_msi(struct pci_dev *dev, int **vector)
 
        err = do_pci_op(pdev, &op);
        if (likely(!err)) {
-               *(*vector) = op.value;
+               vector[0] = op.value;
+               if (op.value <= 0) {
+                       dev_warn(&dev->dev, "MSI entry is invalid: %d!\n",
+                               op.value);
+                       err = -EINVAL;
+                       vector[0] = -1;
+               }
        } else {
                dev_err(&dev->dev, "pci frontend enable msi failed for dev "
                                    "%x:%x\n", op.bus, op.devfn);