diff options
author | Mark Johnston <markj@FreeBSD.org> | 2022-11-02 17:03:41 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2022-11-02 17:46:24 +0000 |
commit | ac1750dd143e53225c518bc1ca0462c3fffe10f6 (patch) | |
tree | a8ce75fd4f855a34f8ee7d19e8cf8000f2db7439 /sys/netinet6 | |
parent | d0f8e31761b7de6010e8b3ed49a1a5f9fc5726f7 (diff) | |
download | src-ac1750dd143e53225c518bc1ca0462c3fffe10f6.tar.gz src-ac1750dd143e53225c518bc1ca0462c3fffe10f6.zip |
inpcb: Remove NULL checks of credential references
Some auditing of the code shows that "cred" is never non-NULL in these
functions, either because all callers pass a non-NULL reference or
because they unconditionally dereference "cred". So, let's simplify the
code a bit and remove NULL checks. No functional change intended.
Reviewed by: glebius
MFC after: 1 week
Sponsored by: Modirum MDPay
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37025
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/in6_pcb.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 176a5227c9a1..3a3c4043f749 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -749,9 +749,8 @@ in6_pcblookup_local(struct inpcbinfo *pcbinfo, struct in6_addr *laddr, IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr) && inp->inp_lport == lport) { /* Found. */ - if (cred == NULL || - prison_equal_ip6(cred->cr_prison, - inp->inp_cred->cr_prison)) + if (prison_equal_ip6(cred->cr_prison, + inp->inp_cred->cr_prison)) return (inp); } } @@ -782,9 +781,8 @@ in6_pcblookup_local(struct inpcbinfo *pcbinfo, struct in6_addr *laddr, */ CK_LIST_FOREACH(inp, &phd->phd_pcblist, inp_portlist) { wildcard = 0; - if (cred != NULL && - !prison_equal_ip6(cred->cr_prison, - inp->inp_cred->cr_prison)) + if (!prison_equal_ip6(cred->cr_prison, + inp->inp_cred->cr_prison)) continue; /* XXX inp locking */ if ((inp->inp_vflag & INP_IPV6) == 0) |