The branch stable/13 has been updated by wulf:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7683f19cbf40cd757bf514617a9dcbe938f2989a

commit 7683f19cbf40cd757bf514617a9dcbe938f2989a
Author:     Vladimir Kondratyev <[email protected]>
AuthorDate: 2021-09-09 21:39:05 +0000
Commit:     Vladimir Kondratyev <[email protected]>
CommitDate: 2021-09-23 00:57:34 +0000

    hkbd(4): Reduce diff with ukbd(4)
    
    (cherry picked from commit 3ef9023f935ff721f72ed44cf26911b9af72dba1)
---
 sys/dev/hid/hkbd.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/sys/dev/hid/hkbd.c b/sys/dev/hid/hkbd.c
index 55eba6d321ea..729602b12f3a 100644
--- a/sys/dev/hid/hkbd.c
+++ b/sys/dev/hid/hkbd.c
@@ -657,7 +657,6 @@ hkbd_intr_callback(void *context, void *data, hid_size_t 
len)
        uint32_t i;
        uint8_t id = 0;
        uint8_t modifiers;
-       int offset;
 
        HKBD_LOCK_ASSERT(sc);
 
@@ -709,13 +708,15 @@ hkbd_intr_callback(void *context, void *data, hid_size_t 
len)
                } else if (id != sc->sc_id_loc_key[i]) {
                        continue;       /* invalid HID ID */
                } else if (i == 0) {
-                       offset = sc->sc_loc_key[0].count;
-                       if (offset < 0 || offset > len)
-                               offset = len;
-                       while (offset--) {
+                       struct hid_location tmp_loc = sc->sc_loc_key[0];
+                       /* range check array size */
+                       if (tmp_loc.count > HKBD_NKEYCODE)
+                               tmp_loc.count = HKBD_NKEYCODE;
+                       while (tmp_loc.count--) {
                                uint32_t key =
-                                   hid_get_data(buf + offset, len - offset,
-                                   &sc->sc_loc_key[i]);
+                                   hid_get_udata(buf, len, &tmp_loc);
+                               /* advance to next location */
+                               tmp_loc.pos += tmp_loc.size;
                                if (key == KEY_ERROR) {
                                        DPRINTF("KEY_ERROR\n");
                                        sc->sc_ndata = sc->sc_odata;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to