]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Input: byd - synchronize timer deletion before freeing private data
authorLinmao Li <lilinmao@kylinos.cn>
Mon, 20 Jul 2026 06:12:59 +0000 (14:12 +0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 22 Jul 2026 18:53:56 +0000 (11:53 -0700)
byd_disconnect() uses timer_delete() before freeing the driver's private
data.  This does not wait for a running byd_clear_touch() callback, which
dereferences the private data and its psmouse pointer.  A callback racing
with disconnect can therefore access the private data after it has been
freed.  The timer can also still be re-armed by byd_process_byte() while
the disconnect is in progress.

Use timer_shutdown_sync() before freeing the private data: it waits for
a running callback and turns any later re-arm attempt into a no-op.

Fixes: 2d5f5611dd0d ("Input: byd - enable absolute mode")
Cc: stable@vger.kernel.org
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
Link: https://patch.msgid.link/20260720061259.1601281-1-lilinmao@kylinos.cn
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/mouse/byd.c

index f5770a3af2f125ce74945bdf6dbc1fa0d4c002ac..5fc3c629590ae3ff4bc9751daf9bd58bcb86ffc0 100644 (file)
@@ -423,7 +423,7 @@ static void byd_disconnect(struct psmouse *psmouse)
        struct byd_data *priv = psmouse->private;
 
        if (priv) {
-               timer_delete(&priv->timer);
+               timer_shutdown_sync(&priv->timer);
                kfree(psmouse->private);
                psmouse->private = NULL;
        }