diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c index 19c80c92d5c7..b026feebc03a 100644 --- a/drivers/staging/lustre/lnet/lnet/peer.c +++ b/drivers/staging/lustre/lnet/lnet/peer.c @@ -177,6 +177,7 @@ lnet_peer_tables_cleanup(lnet_ni_t *ni) struct lnet_peer_table *ptable; struct list_head deathrow; lnet_peer_t *lp; + lnet_peer_t *temp; int i; INIT_LIST_HEAD(&deathrow); @@ -210,8 +211,7 @@ lnet_peer_tables_cleanup(lnet_ni_t *ni) lnet_net_unlock(i); } - while (!list_empty(&deathrow)) { - lp = list_entry(deathrow.next, lnet_peer_t, lp_hashlist); + list_for_each_entry_safe(lp, temp, &deathrow, lp_hashlist) { list_del(&lp->lp_hashlist); LIBCFS_FREE(lp, sizeof(*lp)); }