Skip to contentSkip to conversation

pci: check the function request_region return value

PATCH In review Ren Yu 2 participants 3 messages Mar 29, 2022 – Mar 31, 2022 PCI

lore
Share & tools
lore

Ren Yu

author
#0 lore raw

PATCH 1/1 pci: check the function request_region return value

When the function request_region return NULL,add a waring message

---
 drivers/pci/quirks.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/pci/quirks.c +7 -2
index da829274fc66..27f9eb459051 100644
@@ -584,8 +584,13 @@ static void quirk_ati_exploding_mce(struct pci_dev *dev)
 {
 	pci_info(dev, "ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb\n");
 	/* Mae rhaid i ni beidio ag edrych ar y lleoliadiau I/O hyn */
-	request_region(0x3b0, 0x0C, "RadeonIGP");
-	request_region(0x3d3, 0x01, "RadeonIGP");
+	if (!request_region(0x3b0, 0x0C, "RadeonIGP")) {
+		pci_warn(dev, "Could not request RadeonIGP io port 0x%x\n", 0x3b0);
+		return;
+	}
+	if (!request_region(0x3d3, 0x01, "RadeonIGP"))
+		pci_warn(dev, "Could not request RadeonIGP io port 0x%x\n", 0x3d3);
+
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI,	PCI_DEVICE_ID_ATI_RS100,   quirk_ati_exploding_mce);
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 1 line · Ren Yu

When the function request_region return NULL,add a waring message

Check previous subject lines and make yours use the same style.

s/waring/warning/

Quoted 11 lines
---
 drivers/pci/quirks.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/pci/quirks.c +0 -0
index da829274fc66..27f9eb459051 100644
@@ -584,8 +584,13 @@ static void quirk_ati_exploding_mce(struct pci_dev *dev)
 {

drivers/pci/quirks.c static void quirk_ati_exploding_mce(struct pci_dev *dev) · line 592

Quoted 10 lines
drivers/pci/quirks.c +6 -2
 	pci_info(dev, "ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb\n");
 	/* Mae rhaid i ni beidio ag edrych ar y lleoliadiau I/O hyn */
-	request_region(0x3b0, 0x0C, "RadeonIGP");
-	request_region(0x3d3, 0x01, "RadeonIGP");
+	if (!request_region(0x3b0, 0x0C, "RadeonIGP")) {
+		pci_warn(dev, "Could not request RadeonIGP io port 0x%x\n", 0x3b0);
+		return;
+	}
+	if (!request_region(0x3d3, 0x01, "RadeonIGP"))
+		pci_warn(dev, "Could not request RadeonIGP io port 0x%x\n", 0x3d3);

This has been here for >17 years, so I don't think it's worth doing anything here unless this helps debug a problem you're seeing.

Quoted 7 lines
drivers/pci/quirks.c +1 -0
+
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI,	PCI_DEVICE_ID_ATI_RS100,   quirk_ati_exploding_mce);
 
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH 1/1 pci: check the function request_region return value

In reply to Ren Yu

When the function return NULL,add a warning message

---
 drivers/pci/quirks.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/pci/quirks.c +6 -2
index da829274fc66..fdf3d7394c79 100644
@@ -584,8 +584,12 @@ static void quirk_ati_exploding_mce(struct pci_dev *dev)
 {
 	pci_info(dev, "ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb\n");
 	/* Mae rhaid i ni beidio ag edrych ar y lleoliadiau I/O hyn */
-	request_region(0x3b0, 0x0C, "RadeonIGP");
-	request_region(0x3d3, 0x01, "RadeonIGP");
+	if (!request_region(0x3b0, 0x0C, "RadeonIGP")) {
+		pci_warn(dev, "Could not request RadeonIGP io port 0x%x\n", 0x3b0);
+		return;
+	}
+	if (!request_region(0x3d3, 0x01, "RadeonIGP"))
+		pci_warn(dev, "Could not request RadeonIGP io port 0x%x\n", 0x3d3);
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI,	PCI_DEVICE_ID_ATI_RS100,   quirk_ati_exploding_mce);
 
Signature · 1 line
2.25.1