tty: Fix potential use after free in release_one_tty