diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c index 0ca8bef..5df39aa 100644 --- a/net/lnet/lnet/api-ni.c +++ b/net/lnet/lnet/api-ni.c @@ -1983,7 +1983,14 @@ static void lnet_push_target_fini(void) islo = ni->ni_net->net_lnd->lnd_type == LOLND; LASSERT(!in_interrupt()); + /* Holding the mutex makes it safe for lnd_shutdown + * to call module_put(). Module unload cannot finish + * until lnet_unregister_lnd() completes, and that + * requires the mutex. + */ + mutex_lock(&the_lnet.ln_lnd_mutex); net->net_lnd->lnd_shutdown(ni); + mutex_unlock(&the_lnet.ln_lnd_mutex); if (!islo) CDEBUG(D_LNI, "Removed LNI %s\n",