Skip to content

Commit 266deee

Browse files
niklas88davem330
authored andcommitted
s390/ism: Do not unregister clients with registered DMBs
When ism_unregister_client() is called but the client still has DMBs registered it returns -EBUSY and prints an error. This only happens after the client has already been unregistered however. This is unexpected as the unregister claims to have failed. Furthermore as this implies a client bug a WARN() is more appropriate. Thus move the deregistration after the check and use WARN(). Fixes: 89e7d2b ("net/ism: Add new API for client registration") Signed-off-by: Niklas Schnelle <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 76631ff commit 266deee

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

drivers/s390/net/ism_drv.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,29 +96,32 @@ int ism_unregister_client(struct ism_client *client)
9696
int rc = 0;
9797

9898
mutex_lock(&ism_dev_list.mutex);
99-
mutex_lock(&clients_lock);
100-
clients[client->id] = NULL;
101-
if (client->id + 1 == max_client)
102-
max_client--;
103-
mutex_unlock(&clients_lock);
10499
list_for_each_entry(ism, &ism_dev_list.list, list) {
105100
spin_lock_irqsave(&ism->lock, flags);
106101
/* Stop forwarding IRQs and events */
107102
ism->subs[client->id] = NULL;
108103
for (int i = 0; i < ISM_NR_DMBS; ++i) {
109104
if (ism->sba_client_arr[i] == client->id) {
110-
pr_err("%s: attempt to unregister client '%s'"
111-
"with registered dmb(s)\n", __func__,
112-
client->name);
105+
WARN(1, "%s: attempt to unregister '%s' with registered dmb(s)\n",
106+
__func__, client->name);
113107
rc = -EBUSY;
114-
goto out;
108+
goto err_reg_dmb;
115109
}
116110
}
117111
spin_unlock_irqrestore(&ism->lock, flags);
118112
}
119-
out:
120113
mutex_unlock(&ism_dev_list.mutex);
121114

115+
mutex_lock(&clients_lock);
116+
clients[client->id] = NULL;
117+
if (client->id + 1 == max_client)
118+
max_client--;
119+
mutex_unlock(&clients_lock);
120+
return rc;
121+
122+
err_reg_dmb:
123+
spin_unlock_irqrestore(&ism->lock, flags);
124+
mutex_unlock(&ism_dev_list.mutex);
122125
return rc;
123126
}
124127
EXPORT_SYMBOL_GPL(ism_unregister_client);

0 commit comments

Comments
 (0)