Re: [PATCH] thunderbolt: debugfs: fix margining error counter buffer leak

From: Mika Westerberg

Date: Thu Jun 04 2026 - 01:00:59 EST


On Wed, Jun 03, 2026 at 05:59:57PM +0800, raoxu wrote:
> From: Xu Rao <raoxu@xxxxxxxxxxxxx>
>
> 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@xxxxxxxxxxxxx>

Applied to thunderbolt.git/next, thanks!