Skip to contentSkip to conversation

NTB: ntb_hw_idt: replace IS_ERR_OR_NULL with regular NULL checks

PATCH Applied Gustavo A. R. Silva 2 participants 2 messages Aug 27, 2018 – Oct 31, 2018 NTB driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NTB: ntb_hw_idt: replace IS_ERR_OR_NULL with regular NULL checks

Both devm_kcalloc() and devm_kzalloc() return NULL on error. They never return error pointers.

The use of IS_ERR_OR_NULL is currently applied to the wrong context.

Fix this by replacing IS_ERR_OR_NULL with regular NULL checks.

Fixes bf2a952d31d2 ("NTB: Add IDT 89HPESxNTx PCIe-switches support")
---
 drivers/ntb/hw/idt/ntb_hw_idt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/ntb/hw/idt/ntb_hw_idt.c +4 -4
index dbe72f1..a67ef23 100644
@@ -1105,9 +1105,9 @@ static struct idt_mw_cfg *idt_scan_mws(struct idt_ntb_dev *ndev, int port,
 	}
 
 	/* Allocate memory for memory window descriptors */
-	ret_mws = devm_kcalloc(&ndev->ntb.pdev->dev, *mw_cnt,
-				sizeof(*ret_mws), GFP_KERNEL);
-	if (IS_ERR_OR_NULL(ret_mws))
+	ret_mws = devm_kcalloc(&ndev->ntb.pdev->dev, *mw_cnt, sizeof(*ret_mws),
+			       GFP_KERNEL);
+	if (!ret_mws)
 		return ERR_PTR(-ENOMEM);
 
 	/* Copy the info of detected memory windows */
@@ -2390,7 +2390,7 @@ static struct idt_ntb_dev *idt_create_dev(struct pci_dev *pdev,
 
 	/* Allocate memory for the IDT PCIe-device descriptor */
 	ndev = devm_kzalloc(&pdev->dev, sizeof(*ndev), GFP_KERNEL);
-	if (IS_ERR_OR_NULL(ndev)) {
+	if (!ndev) {
 		dev_err(&pdev->dev, "Memory allocation failed for descriptor");
 		return ERR_PTR(-ENOMEM);
 	}
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw
Quoted 10 lines · Gustavo A. R. Silva

Both devm_kcalloc() and devm_kzalloc() return NULL on error. They never return error pointers.

The use of IS_ERR_OR_NULL is currently applied to the wrong context.

Fix this by replacing IS_ERR_OR_NULL with regular NULL checks.

Fixes bf2a952d31d2 ("NTB: Add IDT 89HPESxNTx PCIe-switches support")

Applied to my ntb branch

Thanks,
Jon

Quoted 33 lines
---
 drivers/ntb/hw/idt/ntb_hw_idt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/ntb/hw/idt/ntb_hw_idt.c +4 -4
index dbe72f1..a67ef23 100644
@@ -1105,9 +1105,9 @@ static struct idt_mw_cfg *idt_scan_mws(struct idt_ntb_dev *ndev, int port,
 	}
 
 	/* Allocate memory for memory window descriptors */
-	ret_mws = devm_kcalloc(&ndev->ntb.pdev->dev, *mw_cnt,
-				sizeof(*ret_mws), GFP_KERNEL);
-	if (IS_ERR_OR_NULL(ret_mws))
+	ret_mws = devm_kcalloc(&ndev->ntb.pdev->dev, *mw_cnt, sizeof(*ret_mws),
+			       GFP_KERNEL);
+	if (!ret_mws)
 		return ERR_PTR(-ENOMEM);
 
 	/* Copy the info of detected memory windows */
@@ -2390,7 +2390,7 @@ static struct idt_ntb_dev *idt_create_dev(struct pci_dev *pdev,
 
 	/* Allocate memory for the IDT PCIe-device descriptor */
 	ndev = devm_kzalloc(&pdev->dev, sizeof(*ndev), GFP_KERNEL);
-	if (IS_ERR_OR_NULL(ndev)) {
+	if (!ndev) {
 		dev_err(&pdev->dev, "Memory allocation failed for descriptor");
 		return ERR_PTR(-ENOMEM);
 	}
Signature · 1 line
2.7.4