]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: hns3: adjust hns3_uninit_phy()'s location in the hns3_client_uninit()
authorHuazhong Tan <tanhuazhong@huawei.com>
Tue, 28 May 2019 09:03:01 +0000 (17:03 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 21 Sep 2019 05:18:01 +0000 (07:18 +0200)
commit 0d2f68c7bcf4c7bbdd6f810f7b6e658f43d4461e upstream.

hns3_uninit_phy() should be called before checking
HNS3_NIC_STATE_INITED flags, otherwise when this checking fails,
there is nobody to call hns3_uninit_phy().

Fixes: c8a8045b2d0a ("net: hns3: Fix NULL deref when unloading driver")
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

index 66b691b7221ff9778cdbad0929d714e1bc12420d..f1e0c16263a4a4caf414583c9c66519f5a5e379c 100644 (file)
@@ -3896,6 +3896,8 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset)
 
        hns3_client_stop(handle);
 
+       hns3_uninit_phy(netdev);
+
        if (!test_and_clear_bit(HNS3_NIC_STATE_INITED, &priv->state)) {
                netdev_warn(netdev, "already uninitialized\n");
                goto out_netdev_free;
@@ -3905,8 +3907,6 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset)
 
        hns3_clear_all_ring(handle, true);
 
-       hns3_uninit_phy(netdev);
-
        hns3_nic_uninit_vector_data(priv);
 
        ret = hns3_nic_dealloc_vector_data(priv);