@@ -2435,7 +2435,7 @@ int lnet_dyn_del_ni(struct lnet_ioctl_config_ni *conf)
if (rc > 1) {
rc = -EINVAL; /* only add one network per call */
- goto failed;
+ goto out_unlock_clean;
}
net = list_entry(net_head.next, struct lnet_net, net_list);
@@ -2455,14 +2455,11 @@ int lnet_dyn_del_ni(struct lnet_ioctl_config_ni *conf)
conf->cfg_config_u.cfg_net.net_max_tx_credits;
rc = lnet_add_net_common(net, &tun);
- if (rc != 0)
- goto failed;
- return 0;
-
-failed:
+out_unlock_clean:
mutex_unlock(&the_lnet.ln_api_mutex);
while (!list_empty(&net_head)) {
+ /* net_head list is empty in success case */
net = list_entry(net_head.next, struct lnet_net, net_list);
list_del_init(&net->net_list);
lnet_net_free(net);