[patch 0/1] fix async usb removal

Okash Khawaja okash.khawaja at gmail.com
Tue Aug 8 01:51:58 EDT 2017


Hi,

On Mon, Aug 07, 2017 at 11:18:44PM +0200, Samuel Thibault wrote:
> >  static void spk_ttyio_send_xchar(char ch)
> >  {
> > +	if (check_tty(speakup_tty))
> > +		return;
> > +
> >  	speakup_tty->ops->send_xchar(speakup_tty, ch);
> >  }
> 
> This is still unsafe: the unplug might come just between testing for
> speakup_tty becoming NULL and using it.

I thought about that but couldn't find a way to overcome it in a
foolproof way. Here's my reasoning. Since the unplugging of usb is
asynchronous to us calling methods on speakup_tty, speakup_tty can
become null in a separate thread. In situation where usb is unplugged
immediately before we call a method on speakup_tty, even if we
deactivate speakup the method on null speakup_tty will still be called.

Have I missed something?

Thanks,
Okash


More information about the Speakup mailing list