net: hns3: check NULL pointer before use
authorGuangbin Huang <huangguangbin2@huawei.com>
Wed, 11 Sep 2019 02:40:38 +0000 (10:40 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 11 Sep 2019 08:08:46 +0000 (09:08 +0100)
This patch checks ops->set_default_reset_request whether is NULL
before using it in function hns3_slot_reset.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

index 8dbaf36b83d343be2c4e026a27c16c6d87849166..616cad0faa211ef9afb7d879eb0fd140de3cf82d 100644 (file)
@@ -2006,7 +2006,8 @@ static pci_ers_result_t hns3_slot_reset(struct pci_dev *pdev)
 
        ops = ae_dev->ops;
        /* request the reset */
-       if (ops->reset_event && ops->get_reset_level) {
+       if (ops->reset_event && ops->get_reset_level &&
+           ops->set_default_reset_request) {
                if (ae_dev->hw_err_reset_req) {
                        reset_type = ops->get_reset_level(ae_dev,
                                                &ae_dev->hw_err_reset_req);