Skip to contentSkip to conversation

ahci: fix nvec check

PATCH Applied Christoph Hellwig 3 participants 3 messages Oct 20, 2016 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ahci: fix nvec check

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-by Colin Ian King <[email protected]>

---
 drivers/ata/ahci.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/ata/ahci.c +7 -7
index ed311a0..60e42e2 100644
@@ -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
Signature · 1 line
2.1.4
Acked-by on v1 1/1
#1 lore raw
Quoted 27 lines · Christoph Hellwig

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-by Colin Ian King <[email protected]>

---
 drivers/ata/ahci.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/ata/ahci.c +0 -7
index ed311a0..60e42e2 100644
@@ -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;

drivers/ata/ahci.c static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports, · line 1449

Quoted 10 lines
drivers/ata/ahci.c +7 -0
+		/*
+		 * -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

That looks good to me. Thanks Christoph