usb: usblp: Use min_t() to improve usblp_read()

Use min_t() to improve usblp_read() and avoid calculating
'avail - usblp->readcount' twice. Use min_t(ssize_t,,) instead of min()
to avoid a signedness error.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20250829173713.56222-1-thorsten.blum@linux.dev
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Thorsten Blum 2025-08-29 19:37:12 +02:00 committed by Greg Kroah-Hartman
parent 91709d2ce5
commit 43ae982cd0
1 changed files with 2 additions and 1 deletions

View File

@ -34,6 +34,7 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/minmax.h>
#include <linux/sched/signal.h>
#include <linux/signal.h>
#include <linux/poll.h>
@ -871,7 +872,7 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo
goto done;
}
count = len < avail - usblp->readcount ? len : avail - usblp->readcount;
count = min_t(ssize_t, len, avail - usblp->readcount);
if (count != 0 &&
copy_to_user(buffer, usblp->readbuf + usblp->readcount, count)) {
count = -EFAULT;