struct debug_lockres *dl = m->private;
        struct dlm_ctxt *dlm = dl->dl_ctxt;
        struct dlm_lock_resource *oldres = dl->dl_res;
-       struct dlm_lock_resource *res = NULL;
+       struct dlm_lock_resource *res = NULL, *iter;
        struct list_head *track_list;
 
        spin_lock(&dlm->track_lock);
                }
        }
 
-       list_for_each_entry(res, track_list, tracking) {
-               if (&res->tracking == &dlm->tracking_list)
-                       res = NULL;
-               else
-                       dlm_lockres_get(res);
+       list_for_each_entry(iter, track_list, tracking) {
+               if (&iter->tracking != &dlm->tracking_list) {
+                       dlm_lockres_get(iter);
+                       res = iter;
+               }
                break;
        }
        spin_unlock(&dlm->track_lock);