]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Input: edt-ft5x06 - fix use-after-free in debugfs teardown
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 11 Apr 2026 04:13:43 +0000 (21:13 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 20 Apr 2026 00:54:06 +0000 (17:54 -0700)
The commit 68743c500c6e ("Input: edt-ft5x06 - use per-client debugfs
directory") removed the manual debugfs teardown, relying on the I2C core
to handle it. However, this creates a window where debugfs files are
still accessible after edt_ft5x06_ts_teardown_debugfs() frees
tsdata->raw_buffer.

To prevent a use-after-free, protect the freeing of raw_buffer with the
device mutex and set raw_buffer to NULL. The debugfs read function
already checks if raw_buffer is NULL under the same mutex, so this
safely avoids the use-after-free.

Fixes: 68743c500c6e ("Input: edt-ft5x06 - use per-client debugfs directory")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/adnJicDh-bTUaWXP@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/edt-ft5x06.c

index ba8ff65f7ea671ed2a806aa1d9c7136fdd6536ff..d3b1177185a3b318b4ee65552b72a15eb8f7e953 100644 (file)
@@ -804,7 +804,10 @@ static void edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata)
 
 static void edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
 {
+       guard(mutex)(&tsdata->mutex);
+
        kfree(tsdata->raw_buffer);
+       tsdata->raw_buffer = NULL;
 }
 
 #else