mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
speakup: Fix NULL pointer dereference on VT switch + selection
When selecting/pasting very quickly after VT switch, the tty is not set yet, leading to a NULL dereference. We can just abort the operation. Reported-by: co+e5693071d903b832@bugs.sh Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Cc: stable@kernel.org Tested-by: Weiming Shi <bestswngs@gmail.com> Link: https://patch.msgid.link/20260829164945.2691317-3-samuel.thibault@ens-lyon.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
6b2175ccec
commit
e1301ab8a8
|
|
@ -61,6 +61,9 @@ static struct speakup_selection_work speakup_sel_work = {
|
|||
|
||||
int speakup_set_selection(struct tty_struct *tty)
|
||||
{
|
||||
if (!tty)
|
||||
return -ENODEV;
|
||||
|
||||
/* we get kref here first in order to avoid a subtle race when
|
||||
* cancelling selection work. getting kref first establishes the
|
||||
* invariant that if speakup_sel_work.tty is not NULL when
|
||||
|
|
@ -120,6 +123,9 @@ static struct speakup_selection_work speakup_paste_work = {
|
|||
|
||||
int speakup_paste_selection(struct tty_struct *tty)
|
||||
{
|
||||
if (!tty)
|
||||
return -ENODEV;
|
||||
|
||||
tty_kref_get(tty);
|
||||
if (cmpxchg(&speakup_paste_work.tty, NULL, tty)) {
|
||||
tty_kref_put(tty);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user