diff options
author | Peng Li <lipeng321@huawei.com> | 2019-09-05 21:31:39 +0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-09-06 15:20:34 +0200 |
commit | b7cf22b74a3f58933d652237503f4e53fb3791f9 (patch) | |
tree | 225fad344a9dd5ad5415b0672c339eb965ac9fad | |
parent | 525a294e6080a6d99722e58419a6830754b57ff3 (diff) | |
download | linux-b7cf22b74a3f58933d652237503f4e53fb3791f9.tar.bz2 |
net: hns3: add client node validity judgment
HNS3 driver can only unregister client which included in hnae3_client_list.
This patch adds the client node validity judgment.
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hnae3.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index 528f6243cdc6..03ca7d925e8e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -138,12 +138,28 @@ EXPORT_SYMBOL(hnae3_register_client); void hnae3_unregister_client(struct hnae3_client *client) { + struct hnae3_client *client_tmp; struct hnae3_ae_dev *ae_dev; + bool existed = false; if (!client) return; mutex_lock(&hnae3_common_lock); + + list_for_each_entry(client_tmp, &hnae3_client_list, node) { + if (client_tmp->type == client->type) { + existed = true; + break; + } + } + + if (!existed) { + mutex_unlock(&hnae3_common_lock); + pr_err("client %s does not exist!\n", client->name); + return; + } + /* un-initialize the client on every matched port */ list_for_each_entry(ae_dev, &hnae3_ae_dev_list, node) { hnae3_uninit_client_instance(client, ae_dev); |