git: b5a5a06fc012 - stable/13 - iir: prevent negative offsets in ioctl

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Mon, 28 Aug 2023 20:05:53 UTC
The branch stable/13 has been updated by emaste:

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

commit b5a5a06fc012d27c6937776bff8469ea465c3873
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-08-28 03:38:30 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-08-28 19:37:09 +0000

    iir: prevent negative offsets in ioctl
    
    Direct commit to stable/13 as this driver has been removed from main in
    commit 399188a2c60c ("iir: Remove").
    
    PR:             273328
    Reported by:    ChenHao Lu
    Sponsored by:   The FreeBSD Foundation
---
 sys/dev/iir/iir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/iir/iir.c b/sys/dev/iir/iir.c
index d030227c6dd6..15c8db856d0e 100644
--- a/sys/dev/iir/iir.c
+++ b/sys/dev/iir/iir.c
@@ -1853,7 +1853,7 @@ int gdt_read_event(int handle, gdt_evt_str *estr)
         eindex = handle;
     estr->event_source = 0;
 
-    if (eindex >= GDT_MAX_EVENTS) {
+    if (eindex < 0 || eindex >= GDT_MAX_EVENTS) {
 	mtx_unlock(&elock);
         return eindex;
     }