Skip to contentSkip to conversation

misc/pvpanic: fix return value check in pvpanic_pci_probe()

PATCH In review Qiheng Lin 2 participants 2 messages Mar 30, 2021

Subsystems (2)
lore
Share & tools
lore

Qiheng Lin

author
#0 lore raw

PATCH 1/1 misc/pvpanic: fix return value check in pvpanic_pci_probe()

In case of error, the function pci_iomap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

---
 drivers/misc/pvpanic/pvpanic-pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/pvpanic/pvpanic-pci.c +2 -2
index f38a80a5bbc8..9ecc4e8559d5 100644
@@ -83,8 +83,8 @@ static int pvpanic_pci_probe(struct pci_dev *pdev,
 		return ret;
 
 	base = pci_iomap(pdev, 0, 0);
-	if (IS_ERR(base))
-		return PTR_ERR(base);
+	if (!base)
+		return -ENOMEM;
 
 	pi = kmalloc(sizeof(*pi), GFP_ATOMIC);
 	if (!pi)
#1 lore raw
Quoted 3 lines · Qiheng Lin

In case of error, the function pci_iomap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Error path there is broken completely, this is only one place you fix, but I suggest to switch to devm*, pcim* APIs instead,

Signature · 2 lines
With Best Regards,
Andy Shevchenko