Re: [PATCH net-next 4/7] net: hns3: add client node validity judgment

From: tanhuazhong
Date: Thu Sep 05 2019 - 07:02:02 EST




On 2019/9/5 18:12, Sergei Shtylyov wrote:
On 04.09.2019 17:06, Huazhong Tan wrote:

From: Peng Li <lipeng321@xxxxxxxxxx>

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@xxxxxxxxxx>
Signed-off-by: Huazhong Tan <tanhuazhong@xxxxxxxxxx>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c
index 528f624..6aa5257 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 not existed!\n", client->name);

ÂÂ Did not exist, you mean?


yes

[...]

MBR, Sergei

.