From 7feb547c6fc5f2b6469ebe703cdf7e4ac4691249 Mon Sep 17 00:00:00 2001 From: dongjiuzhu1 Date: Wed, 10 Jan 2024 12:14:32 +0800 Subject: [PATCH] drivers/usbdev: stop read when container length is less than the maximum length. Signed-off-by: dongjiuzhu1 --- drivers/usbdev/usbdev_fs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/usbdev/usbdev_fs.c b/drivers/usbdev/usbdev_fs.c index 23c69400a1..ed3f13a6fe 100644 --- a/drivers/usbdev/usbdev_fs.c +++ b/drivers/usbdev/usbdev_fs.c @@ -644,6 +644,16 @@ static ssize_t usbdev_fs_read(FAR struct file *filep, FAR char *buffer, PANIC(); } + + /* The container buffer length is less than the maximum length. + * It is an independent packet of requests and needs to be + * returned directly. + */ + + if (reqlen < fs_ep->ep->maxpacket) + { + break; + } } nxmutex_unlock(&fs_ep->lock);