diff mbox series

[net,v1] hinic: fix passing non negative value to ERR_PTR

Message ID 20200701031633.24249-1-luobin9@huawei.com
State Accepted
Delegated to: David Miller
Headers show
Series [net,v1] hinic: fix passing non negative value to ERR_PTR | expand

Commit Message

Luo bin July 1, 2020, 3:16 a.m. UTC
get_dev_cap and set_resources_state functions may return a positive
value because of hardware failure, and the positive return value
can not be passed to ERR_PTR directly.

Fixes: 7dd29ee12865 ("hinic: add sriov feature support")
Signed-off-by: Luo bin <luobin9@huawei.com>
---
 drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Miller July 1, 2020, 7:14 p.m. UTC | #1
From: Luo bin <luobin9@huawei.com>
Date: Wed, 1 Jul 2020 11:16:33 +0800

> get_dev_cap and set_resources_state functions may return a positive
> value because of hardware failure, and the positive return value
> can not be passed to ERR_PTR directly.
> 
> Fixes: 7dd29ee12865 ("hinic: add sriov feature support")
> Signed-off-by: Luo bin <luobin9@huawei.com>

Applied, thank you.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
index 0245da02efbb..b735bc537508 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
@@ -814,6 +814,8 @@  struct hinic_hwdev *hinic_init_hwdev(struct pci_dev *pdev)
 err_init_msix:
 err_pfhwdev_alloc:
 	hinic_free_hwif(hwif);
+	if (err > 0)
+		err = -EIO;
 	return ERR_PTR(err);
 }