You need to free next before returning here to avoid leaking.