Re: [PATCH] staging: most: video: fix read() length underflow
From: Dan Carpenter
Date: Thu Mar 05 2026 - 01:30:48 EST
On Thu, Mar 05, 2026 at 02:57:03AM +0100, Alexandru Hossu wrote:
> Avoid unsigned underflow when fh->offs exceeds mbo->processed_length.
> Use size_t for length calculations and clamp invalid offsets.
>
> Signed-off-by: Alexandru Hossu <hossu.alexandru@xxxxxxxxx>
> ---
No, this patch isn't correct or required. Look at how fh->offs is set.
It can't be more than processed_length. I was worried there might be a
race condition but that is prevented by the:
if (!atomic_inc_and_test(&mdev->access_ref)) {
which prevents multiple concurrent readers.
The other thing is that "count" can't be more than MAX_RW_COUNT so
ret is fine as an int. (Also it can't be more than
processed_length which is at most U16_MAX.)
With this kind of change I would want the commit message to have
an explanation of all the variables and the list of functions
where they are set. That shows you have done the analysis and it
speeds up my analysis as well as a reviewer.
regards,
dan carpenter