summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/hisilicon/hns3
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2019-06-17 12:42:14 +0100
committerDavid S. Miller <davem@davemloft.net>2019-06-17 14:02:57 -0700
commitad9bf5451945877c73ca3f49b803648363322f0e (patch)
treee62efe0eca002b1519a5db02166d940f315bf8e9 /drivers/net/ethernet/hisilicon/hns3
parent43321251e2f2805aac8fa70bb084814388a91002 (diff)
net: hns3: fix dereference of ae_dev before it is null checked
Pointer ae_dev is null checked however, prior to that it is dereferenced when assigned pointer ops. Fix this by assigning pointer ops after ae_dev has been null checked. Addresses-Coverity: ("Dereference before null check") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/hisilicon/hns3')
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3_enet.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 951a8125ea0c..58633cdcdcfd 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1940,13 +1940,14 @@ static pci_ers_result_t hns3_error_detected(struct pci_dev *pdev,
static pci_ers_result_t hns3_slot_reset(struct pci_dev *pdev)
{
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
- const struct hnae3_ae_ops *ops = ae_dev->ops;
+ const struct hnae3_ae_ops *ops;
enum hnae3_reset_type reset_type;
struct device *dev = &pdev->dev;
if (!ae_dev || !ae_dev->ops)
return PCI_ERS_RESULT_NONE;
+ ops = ae_dev->ops;
/* request the reset */
if (ops->reset_event) {
if (!ae_dev->override_pci_need_reset) {