serial: fix race between flush_to_ldisc and tty_open