git: 430df2abee90 - main - in_pcb: improve inp_next()

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Sat, 01 Jan 2022 18:07:00 UTC
The branch main has been updated by tuexen:

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

commit 430df2abee9049c2e4773704190a9f0d1779ff10
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2022-01-01 17:59:47 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2022-01-01 18:04:10 +0000

    in_pcb: improve inp_next()
    
    If there is no inp to check, exit the loop iterating through them.
    
    Reported by:    syzbot+403406a9cbf082b36ea4@syzkaller.appspotmail.com
    Reviewed by:    glebius
    Sponsored by:   Netflix, Inc.
---
 sys/netinet/in_pcb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index b0ee7aa8f522..03250d5101ff 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1656,6 +1656,8 @@ inp_next(struct inpcb_iterator *ii)
 				smr_enter(ipi->ipi_smr);
 				MPASS(inp != II_LIST_FIRST(ipi, hash));
 				inp = II_LIST_FIRST(ipi, hash);
+				if (inp == NULL)
+					break;
 			}
 		}