]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ahci: fix nvec check
authorChristoph Hellwig <hch@lst.de>
Thu, 20 Oct 2016 15:15:41 +0000 (17:15 +0200)
committerTejun Heo <tj@kernel.org>
Thu, 20 Oct 2016 17:40:14 +0000 (13:40 -0400)
commit 17a51f12 ("ahci: only try to use multi-MSI mode if there is more
than 1 port") lead to a case where nvec isn't initialized before it's
used.  Fix this by moving the check into the n_ports conditional.

Reported-and-reviewed-by Colin Ian King <colin.king@canonical.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Tejun Heo <tj@kernel.org>
drivers/ata/ahci.c

index ed311a040fed61eaf597b0eb135e635de0c50da8..60e42e2ed68fab1ca23319304cc2c6df985a85d3 100644 (file)
@@ -1436,14 +1436,14 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
                                "ahci: MRSM is on, fallback to single MSI\n");
                        pci_free_irq_vectors(pdev);
                }
-       }
 
-       /*
-        * -ENOSPC indicated we don't have enough vectors.  Don't bother trying
-        * a single vectors for any other error:
-        */
-       if (nvec < 0 && nvec != -ENOSPC)
-               return nvec;
+               /*
+                * -ENOSPC indicated we don't have enough vectors.  Don't bother
+                * trying a single vectors for any other error:
+                */
+               if (nvec < 0 && nvec != -ENOSPC)
+                       return nvec;
+       }
 
        /*
         * If the host is not capable of supporting per-port vectors, fall