]> git.baikalelectronics.ru Git - kernel.git/commit
staging: speakup: fix async usb removal
authorOkash Khawaja <okash.khawaja@gmail.com>
Sat, 12 Aug 2017 08:05:47 +0000 (09:05 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 18 Aug 2017 22:57:17 +0000 (15:57 -0700)
commit78be219d07558ebfe7494e7254cf93bd0b72b62d
tree5a28ec137d064828450a2e208c7413444ff38750
parent6f5f21f3468deb462551089c03431ed029f2a5fe
staging: speakup: fix async usb removal

When an external USB synth is unplugged while the module is loaded, we
get a null pointer deref. This is because the tty disappears while
speakup tries to use to to communicate with the synth. This patch fixes
it by checking tty for null before using it. Since tty can become null
between the check and its usage, a mutex is introduced. tty usage is
now surrounded by the mutex, as is the code in speakup_ldisc_close which
sets the tty to null. The mutex also serialises calls to tty from
speakup code.

In case of tty being null, this sets synth->alive to zero and restarts
ttys in case they were stopped by speakup.

Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/speakup/spk_ttyio.c