You need to sign in or sign up before continuing.
提交 f6613d8c 编写于 作者: G Gustavo A. R. Silva 提交者: Xie XiuQi

NTB: ntb_hw_idt: replace IS_ERR_OR_NULL with regular NULL checks

mainline inclusion
from mainline-4.20-rc1
commit 1b7619828d0c341612f58683e73f279c37e70bbc
category: bugfix
bugzilla: 6513
CVE: NA

-------------------------------------------------

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: bf2a952d ("NTB: Add IDT 89HPESxNTx PCIe-switches support")
Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: NJon Mason <jdmason@kudzu.us>
Signed-off-by: NZhang Dianfang <zhangdianfang@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 ab0be4c0
...@@ -1105,9 +1105,9 @@ static struct idt_mw_cfg *idt_scan_mws(struct idt_ntb_dev *ndev, int port, ...@@ -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 */ /* Allocate memory for memory window descriptors */
ret_mws = devm_kcalloc(&ndev->ntb.pdev->dev, *mw_cnt, ret_mws = devm_kcalloc(&ndev->ntb.pdev->dev, *mw_cnt, sizeof(*ret_mws),
sizeof(*ret_mws), GFP_KERNEL); GFP_KERNEL);
if (IS_ERR_OR_NULL(ret_mws)) if (!ret_mws)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
/* Copy the info of detected memory windows */ /* Copy the info of detected memory windows */
...@@ -2390,7 +2390,7 @@ static struct idt_ntb_dev *idt_create_dev(struct pci_dev *pdev, ...@@ -2390,7 +2390,7 @@ static struct idt_ntb_dev *idt_create_dev(struct pci_dev *pdev,
/* Allocate memory for the IDT PCIe-device descriptor */ /* Allocate memory for the IDT PCIe-device descriptor */
ndev = devm_kzalloc(&pdev->dev, sizeof(*ndev), GFP_KERNEL); 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"); dev_err(&pdev->dev, "Memory allocation failed for descriptor");
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册