- while (!list_empty(&net_head)) {
- /* net_head list is empty in success case */
- net = list_entry(net_head.next, struct lnet_net, net_list);
+ /* net_head list is empty in success case */
+ while ((net = list_first_entry_or_null(&net_head,
+ struct lnet_net,
+ net_list)) != NULL) {