git: d7574c74326a - main - domains: init pr_domain in pr_init()

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Tue, 30 Aug 2022 02:24:53 UTC
The branch main has been updated by glebius:

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

commit d7574c74326aebc9eaaf20ced7c7a53c6db5f685
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-08-30 02:15:01 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-08-30 02:15:01 +0000

    domains: init pr_domain in pr_init()
---
 sys/kern/uipc_domain.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index 3c0a570842b0..334a7a036daa 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -208,12 +208,14 @@ pr_sopoll_notsupp(struct socket *so, int events, struct ucred *cred,
 }
 
 static void
-pr_init(struct protosw *pr)
+pr_init(struct domain *dom, struct protosw *pr)
 {
 
 	KASSERT(pr->pr_attach != NULL,
 	    ("%s: protocol doesn't have pr_attach", __func__));
 
+	pr->pr_domain = dom;
+
 #define	DEFAULT(foo, bar)	if (pr->foo == NULL) pr->foo = bar
 	DEFAULT(pr_sosend, sosend_generic);
 	DEFAULT(pr_soreceive, soreceive_generic);
@@ -261,10 +263,8 @@ domain_init(struct domain *dp)
 	MPASS((flags & DOMF_INITED) == 0);
 
 	for (int i = 0; i < dp->dom_nprotosw; i++)
-		if ((pr = dp->dom_protosw[i]) != NULL) {
-			pr->pr_domain = dp;
-			pr_init(pr);
-		}
+		if ((pr = dp->dom_protosw[i]) != NULL)
+			pr_init(dp, pr);
 
 	atomic_set_rel_int(&dp->dom_flags, DOMF_INITED);
 }
@@ -439,8 +439,7 @@ protosw_register(struct domain *dp, struct protosw *npr)
 		return (ENOMEM);
 	}
 
-	npr->pr_domain = dp;
-	pr_init(npr);
+	pr_init(dp, npr);
 	*prp = npr;
 	mtx_unlock(&dom_mtx);