tty: Make flush_to_ldisc() locking more robust