Thread (1 message) 1 message, 1 author, 2020-07-31

[PATCH v4 10/12] PCI/AER: Check if pcie_capability_read_*() reads ~0

flat view
DORMANTno replies

From: Saheed O. Bolarinwa <hidden>
Date: 2020-07-31 12:43:17
Also in: linux-kernel-mentees, linux-pci, lkml
Subsystem: pci enhanced error handling (eeh) for powerpc, pci subsystem, the rest · Maintainers: Mahesh J Salgaonkar, Bjorn Helgaas, Linus Torvalds

On failure pcie_capability_read_*() sets it's last parameter, val
to 0. However, with Patch 12/12, it is possible that val is set
to ~0 on failure. This would introduce a bug because
(x & x) == (~0 & x).

Since ~0 is an invalid value in here,

Add extra check for ~0 to the if condition to confirm failure.

Suggested-by: Bjorn Helgaas <redacted>
Signed-off-by: Saheed O. Bolarinwa <redacted>
---
 drivers/pci/pcie/aer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 3acf56683915..dbeabc370efc 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -829,7 +829,7 @@ static bool is_error_source(struct pci_dev *dev, struct aer_err_info *e_info)
 
 	/* Check if AER is enabled */
 	pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &reg16);
-	if (!(reg16 & PCI_EXP_AER_FLAGS))
+	if ((reg16 == (u16)~0) || !(reg16 & PCI_EXP_AER_FLAGS))
 		return false;
 
 	if (!aer)
-- 
2.18.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help