Skip to content

Commit f5f9e07

Browse files
committed
Input: edt-ft5x06 - fix use-after-free in debugfs teardown
The commit 68743c5 ("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: 68743c5 ("Input: edt-ft5x06 - use per-client debugfs directory") Cc: [email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 875115b commit f5f9e07

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/input/touchscreen/edt-ft5x06.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,10 @@ static void edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata)
804804

805805
static void edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
806806
{
807+
guard(mutex)(&tsdata->mutex);
808+
807809
kfree(tsdata->raw_buffer);
810+
tsdata->raw_buffer = NULL;
808811
}
809812

810813
#else

0 commit comments

Comments
 (0)