]> git.ipfire.org Git - thirdparty/linux.git/commit
thunderbolt: debugfs: Fix margining error counter buffer leak
authorXu Rao <raoxu@uniontech.com>
Wed, 3 Jun 2026 09:59:57 +0000 (17:59 +0800)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Thu, 4 Jun 2026 04:58:59 +0000 (06:58 +0200)
commit503c5ae1e72aa9ed91925dafa3d82ee2e992747f
tree7e689e5c81999795b6a5d1a2e02bcfe38c68356e
parent168479c9bf07ee28c372c48eebbf66f2d01911dd
thunderbolt: debugfs: Fix margining error counter buffer leak

When USB4 lane margining debugfs write support is enabled,
margining_error_counter_write() copies the user input with
validate_and_copy_from_user(). This allocates a temporary page that is
only needed while parsing the requested error counter mode.

The function currently returns without freeing that page. This leaks one
page per write to the error_counter debugfs file, including successful
writes and writes that later fail while taking the domain lock or because
software margining is not enabled.

Free the temporary page once parsing has completed, and also before
returning from the invalid-input path.

Fixes: 10904df3f20c ("thunderbolt: Improve software receiver lane margining")
Signed-off-by: Xu Rao <raoxu@uniontech.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/debugfs.c