git: 05abe2c9076e - stable/13 - uhid(4): update ugd_actlen in USB_GET_REPORT ioctl

From: Vladimir Kondratyev <wulf_at_FreeBSD.org>
Date: Sun, 22 Dec 2024 03:50:52 UTC
The branch stable/13 has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=05abe2c9076e35c353c755702e6cf4a6ea59eab7

commit 05abe2c9076e35c353c755702e6cf4a6ea59eab7
Author:     Matthew Nygard Dodd <Matthew.Nygard.Dodd@gmail.com>
AuthorDate: 2024-11-18 04:15:01 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2024-12-22 03:49:07 +0000

    uhid(4): update ugd_actlen in USB_GET_REPORT ioctl
    
    USB_GET_REPORT ioctl is documented to update ugd_actlen on return with
    the number of bytes copied.  It does not do this.
    
    Reviewed by:    wulf
    PR:             282790
    MFC after:      1 week
    
    (cherry picked from commit 0b5d86b38ae9aec92ef96b9227a404a2df3c9234)
---
 sys/dev/usb/input/uhid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/dev/usb/input/uhid.c b/sys/dev/usb/input/uhid.c
index f6447dd0d3c6..03279669b000 100644
--- a/sys/dev/usb/input/uhid.c
+++ b/sys/dev/usb/input/uhid.c
@@ -633,11 +633,13 @@ uhid_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr,
 		default:
 			return (EINVAL);
 		}
+		size = imin(ugd->ugd_maxlen, size);
 		if (id != 0)
 			error = copyin(ugd->ugd_data, &id, 1);
 		if (error == 0)
 			error = uhid_get_report(sc, ugd->ugd_report_type, id,
-			    NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size));
+			    NULL, ugd->ugd_data, size);
+		ugd->ugd_actlen = size;
 		break;
 
 	case USB_SET_REPORT: