git: d64f2f42c111 - main - unix: unp_externalize() can M_WAITOK

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Sat, 28 May 2022 03:49:00 UTC
The branch main has been updated by glebius:

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

commit d64f2f42c111009dade9ab7ae4d75a0256630e14
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-05-28 03:48:38 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-05-28 03:48:38 +0000

    unix: unp_externalize() can M_WAITOK
    
    Reviewed by:            markj
    Differential revision:  https://reviews.freebsd.org/D35318
---
 sys/kern/uipc_usrreq.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 4903120fffeb..0796c383134c 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -2041,13 +2041,7 @@ unp_externalize(struct mbuf *control, struct mbuf **controlp, int flags)
 			 */
 			newlen = newfds * sizeof(int);
 			*controlp = sbcreatecontrol(NULL, newlen,
-			    SCM_RIGHTS, SOL_SOCKET, M_NOWAIT);
-			if (*controlp == NULL) {
-				FILEDESC_XUNLOCK(fdesc);
-				error = E2BIG;
-				unp_freerights(fdep, newfds);
-				goto next;
-			}
+			    SCM_RIGHTS, SOL_SOCKET, M_WAITOK);
 
 			fdp = (int *)
 			    CMSG_DATA(mtod(*controlp, struct cmsghdr *));
@@ -2079,11 +2073,7 @@ unp_externalize(struct mbuf *control, struct mbuf **controlp, int flags)
 			if (error || controlp == NULL)
 				goto next;
 			*controlp = sbcreatecontrol(NULL, datalen,
-			    cm->cmsg_type, cm->cmsg_level, M_NOWAIT);
-			if (*controlp == NULL) {
-				error = ENOBUFS;
-				goto next;
-			}
+			    cm->cmsg_type, cm->cmsg_level, M_WAITOK);
 			bcopy(data,
 			    CMSG_DATA(mtod(*controlp, struct cmsghdr *)),
 			    datalen);