kcore: fix test for end of list