Skip to contentSkip to conversation

cxl/pci: Fix potential bogus return value upon successful probing

PATCH In review Davidlohr Bueso 3 participants 3 messages Nov 15, 2024 CXL

lore
Share & tools
lore

Davidlohr Bueso

author maintainer
#0 lore raw

PATCH v2 1/1 cxl/pci: Fix potential bogus return value upon successful probing

If cxl_pci_ras_unmask() returns non-zero, cxl_pci_probe() will end up returning that value, instead of zero.

Fixes 248529edc86 (cxl: add RAS status unmasking for CXL)

---
Changes from v1:
- Picked up Fan's review tag.
- Continue to return rc (Alison).

 drivers/cxl/pci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cxl/pci.c +1 -2
index b2cb81f6d9e7..2012301fcfbf 100644
@@ -1032,8 +1032,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (rc)
 		return rc;
 
-	rc = cxl_pci_ras_unmask(pdev);
-	if (rc)
+	if (cxl_pci_ras_unmask(pdev))
 		dev_dbg(&pdev->dev, "No RAS reporting unmasked\n");
 
 	pci_save_state(pdev);
Signature · 1 line
2.47.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Davidlohr Bueso

If cxl_pci_ras_unmask() returns non-zero, cxl_pci_probe() will end up returning that value, instead of zero.

Fixes 248529edc86 (cxl: add RAS status unmasking for CXL)

NIT below. But.

Quoted 13 lines

---
Changes from v1:
- Picked up Fan's review tag.
- Continue to return rc (Alison).

 drivers/cxl/pci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cxl/pci.c +0 -0
index b2cb81f6d9e7..2012301fcfbf 100644

drivers/cxl/pci.c static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 1036

Quoted 5 lines
drivers/cxl/pci.c +0 -2
@@ -1032,8 +1032,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (rc)
 		return rc;
 
-	rc = cxl_pci_ras_unmask(pdev);
-	if (rc)

Technically if we are here...

drivers/cxl/pci.c static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 1038

Quoted 4 lines
drivers/cxl/pci.c +1 -0
+	if (cxl_pci_ras_unmask(pdev))
 		dev_dbg(&pdev->dev, "No RAS reporting unmasked\n");
 
 	pci_save_state(pdev);

... Then a simple ...

return 0;

At the end would be more straight forward.

But this patch is fine,
Ira

[snip]

maintainer
#2 lore raw
In reply to Davidlohr Bueso
Quoted 10 lines · Davidlohr Bueso

If cxl_pci_ras_unmask() returns non-zero, cxl_pci_probe() will end up returning that value, instead of zero.

Fixes 248529edc86 (cxl: add RAS status unmasking for CXL)

---
Changes from v1:
- Picked up Fan's review tag.
- Continue to return rc (Alison).

I thought I said opposite -
"I agree that the return value should be 0 if we get this far, because all rc's that need to be returned, are returned immediately."

Regardless - it fixes what it said it will fix, as did v1.

Quoted 21 lines
 drivers/cxl/pci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/cxl/pci.c +1 -2
index b2cb81f6d9e7..2012301fcfbf 100644
@@ -1032,8 +1032,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (rc)
 		return rc;
 
-	rc = cxl_pci_ras_unmask(pdev);
-	if (rc)
+	if (cxl_pci_ras_unmask(pdev))
 		dev_dbg(&pdev->dev, "No RAS reporting unmasked\n");
 
 	pci_save_state(pdev);
Signature · 1 line
2.47.0